17 error_t parse_opt(int, char*, struct argp_state *);
19 const char *argp_program_version = "Variations on Rockdodger " VERSION;
20 const char *argp_program_bug_address = "<josh@qualdan.com>";
21 static char doc[] = "Dodge the rocks until you die.";
22 static struct argp_option opts[] = {
23 {0, 0, 0, 0, "Gameplay Variations:"},
24 {"bounciness", 'b', "N%", 0, "Keep N% of speed when hitting edges (default 50%)"},
25 {"game-speed", 'g', "N%", 0, "50-100% (default 100%)"},
26 {"max-lead", 'l', "#SCREENS", 0, "Max dist. ahead you can get (default 1 screen)\n(negative value means no limit)"},
27 {"bad-physics", 'p', 0, 0, "Bad physics (i.e. friction)"},
28 {0, 0, 0, 0, "Look and Feel:"},
29 {"engine", 'e', 0, 0, "Display large tail plume"},
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 };
42 // Gameplay Variations
43 opt_bounciness = 0.50; // lose 50% when you hit the screen edge.
44 opt_gamespeed = 1.00; // Run game at full speed.
45 opt_max_lead = 1.00*XSIZE; // you can get 1 screen ahead.
56 parse_opt(int key, char *arg, struct argp_state *state)
61 case 'b': if(!sscanf(arg, "%d%%", &i)) {
62 argp_error(state, "bad --bounciness (-b) value (should be 0-100%%)");
65 if(i < 50) i = 50; else if(i > 100) i = 100;
66 opt_bounciness = (float)i / 100;
68 case 'e': opt_tail_engine = 1; break;
69 case 'f': opt_fullscreen = 1; break;
70 case 'g': if(!sscanf(arg, "%d%%", &i)) {
71 argp_error(state, "bad --gamespeed (-g) value (should be 50-100%%)");
74 if(i < 0) i = 0; else if(i > 100) i = 100;
75 opt_gamespeed = (float)i / 100;
77 case 'l': if(!sscanf(arg, "%f", &opt_max_lead)) {
78 argp_error(state, "bad --max-limit (-l) value (must be a number)");
81 opt_max_lead *= XSIZE;
83 case 'm': opt_music = 1; break;
84 case 'p': opt_friction = 1; break;
85 case 's': opt_sound = 0; opt_music = 0; break;