15 error_t parse_opt(int, char*, struct argp_state *);
17 const char *argp_program_version = "Variations on Rockdodger " VERSION;
18 const char *argp_program_bug_address = "<josh@qualdan.com>";
19 static char doc[] = "Dodge the rocks until you die.";
20 static struct argp_option opts[] = {
21 {0, 0, 0, 0, "Gameplay Variations:"},
22 {"bounciness", 'b', "N%", 0, "Keep N% of speed when hitting edges (default 50%)"},
23 {"game-speed", 'g', "N%", 0, "50-100% (default 100%)"},
24 {"max-lead", 'l', "#SCREENS", OPTION_HIDDEN,
25 "Max distance ahead you can get\n (default 1 screen; < 0 means no limit)"},
26 {0, 0, 0, 0, "Look and Feel:"},
27 {"full-screen", 'f', 0, 0, ""},
28 {"music", 'm', 0, 0, "Enable music"},
29 {"silent", 's', 0, 0, "No explosion sounds or music"},
30 {0, 0, 0, 0, "Informational:", -1},
34 struct argp argp = { opts, &parse_opt, 0, doc };
39 // Gameplay Variations
40 opt_bounciness = 0.50; // lose 50% when you hit the screen edge.
41 opt_gamespeed = 1.00; // Run game at full speed.
42 opt_max_lead = 1.00*XSIZE; // you can get 1 screen ahead.
51 parse_opt(int key, char *arg, struct argp_state *state)
56 case 'b': if(!sscanf(arg, "%d%%", &i)) {
57 fprintf(stderr, "bad --bounciness (-b) value (should be 0-100%%)\n");
58 argp_state_help(state, stderr, ARGP_HELP_STD_HELP);
61 if(i < 50) i = 50; else if(i > 100) i = 100;
62 opt_bounciness = (float)i / 100;
64 case 'f': opt_fullscreen = 1; break;
65 case 'g': if(!sscanf(arg, "%d%%", &i)) {
66 fprintf(stderr, "bad --gamespeed (-g) value (should be 50-100%%)\n");
67 argp_state_help(state, stderr, ARGP_HELP_STD_HELP);
70 if(i < 0) i = 0; else if(i > 100) i = 100;
71 opt_gamespeed = (float)i / 100;
73 case 'l': if(!sscanf(arg, "%f", &opt_max_lead)) {
74 fprintf(stderr, "bad --max-lead (-l) value (must be a number)\n");
75 argp_state_help(state, stderr, ARGP_HELP_STD_HELP);
78 opt_max_lead *= XSIZE;
80 case 'm': opt_music = 1; break;
81 case 's': opt_sound = 0; opt_music = 0; break;
82 default: return ARGP_ERR_UNKNOWN;