JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Added constant SCREENDXMIN instead of using 7.5 everywhere.
authorJoshua Grams <josh@qualdan.com>
Mon, 4 Jul 2005 16:50:12 +0000 (16:50 +0000)
committerJoshua Grams <josh@qualdan.com>
Mon, 4 Jul 2005 16:50:12 +0000 (16:50 +0000)
Fixed options array so the help displays properly.
Removed some stupid stuff from rocks.c.

config.h
main.c
rocks.c

index c815082..2eaf0ab 100644 (file)
--- a/config.h
+++ b/config.h
@@ -17,6 +17,8 @@
 #define I_ROCKS 25  // initial/final counts for rocks-on-screen.
 #define F_ROCKS 45
 
 #define I_ROCKS 25  // initial/final counts for rocks-on-screen.
 #define F_ROCKS 45
 
+#define SCREENDXMIN 7.5
+
 #define MAXROCKS 120 // MAX Rocks
 #define ROCKRATE 2
 #define MAXENGINEDOTS 5000
 #define MAXROCKS 120 // MAX Rocks
 #define ROCKRATE 2
 #define MAXENGINEDOTS 5000
diff --git a/main.c b/main.c
index 359e59f..a161720 100644 (file)
--- a/main.c
+++ b/main.c
@@ -80,14 +80,14 @@ const char *argp_program_version = "Variations on Rockdodger " VERSION;
 const char *argp_program_bug_address = "<josh@qualdan.com>";
 static char doc[] = "VoR: Dodge the rocks until you die.";
 static struct argp_option opts[] = {
 const char *argp_program_bug_address = "<josh@qualdan.com>";
 static char doc[] = "VoR: Dodge the rocks until you die.";
 static struct argp_option opts[] = {
-       {0, 0, 0, 0, "Basic Options:", 0},
-       {"full-screen", 'f', 0, 0, "", 0},
-       {"music", 'm', 0, 0, "Enable music", 0},
-       {"silent", 's', 0, 0, "Turn off explosion sounds", 0},
-       {0, 0, 0, 0, "Gameplay Options:", 1},
-       {"game-speed", 'g', "N%", 0, "Game speed [50-100%]", 1},
-       {"engine", 'e', 0, 0, "Display large tail plume", 1},
-       {"old-physics", 'p', 0, 0, "Original physics (i.e. friction).", 1},
+       {0, 0, 0, 0, "Basic Options:"},
+       {"full-screen", 'f', 0, 0, ""},
+       {"music", 'm', 0, 0, "Enable music"},
+       {"silent", 's', 0, 0, "Turn off explosion sounds"},
+       {0, 0, 0, 0, "Gameplay Options:"},
+       {"game-speed", 'g', "N%", 0, "Game speed [50-100%]"},
+       {"engine", 'e', 0, 0, "Display large tail plume"},
+       {"old-physics", 'p', 0, 0, "Original physics (i.e. friction)."},
        {0}
 };
 error_t parse_opt(int, char*, struct argp_state *);
        {0}
 };
 error_t parse_opt(int, char*, struct argp_state *);
@@ -96,8 +96,8 @@ static struct argp argp = { opts, &parse_opt, 0, doc };
 
 struct shape shipshape;
 float shipx = XSIZE/2, shipy = YSIZE/2;        // X position, 0..XSIZE
 
 struct shape shipshape;
 float shipx = XSIZE/2, shipy = YSIZE/2;        // X position, 0..XSIZE
-float shipdx = 7.5, shipdy = 0.0;      // Change in X position per tick.
-float screendx = 7.5, screendy = 0.0;
+float shipdx = SCREENDXMIN, shipdy = 0.0;      // Change in X position per tick.
+float screendx = SCREENDXMIN, screendy = 0.0;
 float xscroll, yscroll;
 float gamerate;  // this controls the speed of everything that moves.
 
 float xscroll, yscroll;
 float gamerate;  // this controls the speed of everything that moves.
 
@@ -766,7 +766,7 @@ gameloop() {
                        tmp /= -25;
                        tmp = ((screendx * (gamerate - 12)) + (tmp * gamerate)) / 12;
                        screendx = -tmp;
                        tmp /= -25;
                        tmp = ((screendx * (gamerate - 12)) + (tmp * gamerate)) / 12;
                        screendx = -tmp;
-                       if(screendx < 7.5) screendx=7.5;
+                       if(screendx < SCREENDXMIN) screendx=SCREENDXMIN;
 
                        xscroll = screendx * gamerate;
                        yscroll = screendy * gamerate;
 
                        xscroll = screendx * gamerate;
                        yscroll = screendy * gamerate;
@@ -801,6 +801,7 @@ gameloop() {
                                bangx = shipx; bangy = shipy; bangdx = shipdx; bangdy = shipdy;
                                make_bang_dots(shipx,shipy,shipdx,shipdy,surf_ship,30);
                                shipdx *= 0.5; shipdy *= 0.5;
                                bangx = shipx; bangy = shipy; bangdx = shipdx; bangdy = shipdy;
                                make_bang_dots(shipx,shipy,shipdx,shipdy,surf_ship,30);
                                shipdx *= 0.5; shipdy *= 0.5;
+                               if(shipdx < SCREENDXMIN) shipdx = SCREENDXMIN;
                                if(--nships <= 0) {
                                        state = GAME_OVER;
                                        gameover = 1;
                                if(--nships <= 0) {
                                        state = GAME_OVER;
                                        gameover = 1;
diff --git a/rocks.c b/rocks.c
index 76663c6..89fe3a2 100644 (file)
--- a/rocks.c
+++ b/rocks.c
@@ -25,10 +25,6 @@ struct shape rock_shapes[NROCKS];
 // timers for rock generation.
 float rtimers[4];
 
 // timers for rock generation.
 float rtimers[4];
 
-int32_t rcnt, lrcnt;
-int32_t rsum, rsamples;
-float ravg;
-
 uint32_t nrocks;
 uint32_t nrocks_timer;
 uint32_t nrocks_inc_ticks = 2*60*1000/(F_ROCKS-I_ROCKS);
 uint32_t nrocks;
 uint32_t nrocks_timer;
 uint32_t nrocks_inc_ticks = 2*60*1000/(F_ROCKS-I_ROCKS);
@@ -68,8 +64,6 @@ reset_rocks(void)
        for(i = 0; i<MAXROCKS; i++) rock[i].active = 0;
        nrocks = I_ROCKS;
        nrocks_timer = 0;
        for(i = 0; i<MAXROCKS; i++) rock[i].active = 0;
        nrocks = I_ROCKS;
        nrocks_timer = 0;
-       rcnt = 0; lrcnt = -1;
-       rsum = 0; rsamples = 0;
 }
 
 enum { LEFT, RIGHT, TOP, BOTTOM };
 }
 
 enum { LEFT, RIGHT, TOP, BOTTOM };
@@ -93,48 +87,44 @@ rock_sides(float *ti, float *speed_min, float *speed_max)
        dx0 = -RDX - screendx; dx1 = RDX - screendx;
        dy0 = -RDY - screendy; dy1 = RDY - screendy;
 
        dx0 = -RDX - screendx; dx1 = RDX - screendx;
        dy0 = -RDY - screendy; dy1 = RDY - screendy;
 
-       if(dx0 != 0) {
-               if(dx0 < 0) {
-                       speed_max[RIGHT] = -dx0;
-                       if(dx1 < 0) {
-                               // Rocks moving left only. So the RIGHT side of the screen
-                               speed_min[RIGHT] = -dx1;
-                               ti[RIGHT] = -(dx0+dx1)/2;
-                       } else {
-                               // Rocks moving left and right
-                               speed_max[LEFT] = dx1;
-                               ti[RIGHT] = -dx0/2;
-                               ti[LEFT] = dx1/2;
-                       }
+       if(dx0 < 0) {
+               speed_max[RIGHT] = -dx0;
+               if(dx1 < 0) {
+                       // Rocks moving left only. So the RIGHT side of the screen
+                       speed_min[RIGHT] = -dx1;
+                       ti[RIGHT] = -(dx0+dx1)/2;
                } else {
                } else {
-                       // Rocks moving right only. So the LEFT side of the screen
-                       speed_min[LEFT] = dx0;
+                       // Rocks moving left and right
                        speed_max[LEFT] = dx1;
                        speed_max[LEFT] = dx1;
-                       ti[LEFT] = (dx0+dx1)/2;
+                       ti[RIGHT] = -dx0/2;
+                       ti[LEFT] = dx1/2;
                }
                }
+       } else {
+               // Rocks moving right only. So the LEFT side of the screen
+               speed_min[LEFT] = dx0;
+               speed_max[LEFT] = dx1;
+               ti[LEFT] = (dx0+dx1)/2;
        }
        ti[LEFT] *= hfactor;
        ti[RIGHT] *= hfactor;
 
        }
        ti[LEFT] *= hfactor;
        ti[RIGHT] *= hfactor;
 
-       if(dy0 != 0) {
-               if(dy0 < 0) {
-                       speed_max[BOTTOM] = -dy0;
-                       if(dy1 < 0) {
-                               // Rocks moving up only. So the BOTTOM of the screen
-                               speed_min[BOTTOM] = -dy1;
-                               ti[BOTTOM] = -(dy0+dy1)/2;
-                       } else {
-                               // Rocks moving up and down
-                               speed_max[TOP] = dy1;
-                               ti[BOTTOM] = -dy0/2;
-                               ti[TOP] = dy1/2;
-                       }
+       if(dy0 < 0) {
+               speed_max[BOTTOM] = -dy0;
+               if(dy1 < 0) {
+                       // Rocks moving up only. So the BOTTOM of the screen
+                       speed_min[BOTTOM] = -dy1;
+                       ti[BOTTOM] = -(dy0+dy1)/2;
                } else {
                } else {
-                       // Rocks moving down only. so the TOP of the screen
-                       speed_min[TOP] = dy0;
+                       // Rocks moving up and down
                        speed_max[TOP] = dy1;
                        speed_max[TOP] = dy1;
-                       ti[TOP] = (dy0+dy1)/2;
+                       ti[BOTTOM] = -dy0/2;
+                       ti[TOP] = dy1/2;
                }
                }
+       } else {
+               // Rocks moving down only. so the TOP of the screen
+               speed_min[TOP] = dy0;
+               speed_max[TOP] = dy1;
+               ti[TOP] = (dy0+dy1)/2;
        }
        ti[TOP] *= vfactor;
        ti[BOTTOM] *= vfactor;
        }
        ti[TOP] *= vfactor;
        ti[BOTTOM] *= vfactor;
@@ -210,7 +200,6 @@ new_rocks(void)
                                }
 
                                rockptr->active = 1;
                                }
 
                                rockptr->active = 1;
-                               rcnt++;
                        }
                }
        }
                        }
                }
        }
@@ -231,19 +220,9 @@ move_rocks(void)
                        if(rock[i].x < -rock[i].image->w || rock[i].x >= XSIZE
                                        || rock[i].y < -rock[i].image->h || rock[i].y >= YSIZE) {
                                rock[i].active = 0;
                        if(rock[i].x < -rock[i].image->w || rock[i].x >= XSIZE
                                        || rock[i].y < -rock[i].image->h || rock[i].y >= YSIZE) {
                                rock[i].active = 0;
-                               rcnt--;
                        }
                }
        }
                        }
                }
        }
-       /*
-       if(lrcnt == -1 && rcnt == nrocks) lrcnt = 0;
-       if(rcnt != lrcnt && lrcnt != -1) {
-               lrcnt = rcnt;
-               rsum += rcnt-nrocks; rsamples++;
-               ravg = (float) rsum / rsamples;
-               printf("%.2f%%\n", 100.0 * ravg / nrocks);
-       }
-       */
 }
 
 void
 }
 
 void