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