JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fixed messages
[vor.git] / rocks.c
diff --git a/rocks.c b/rocks.c
index 89efb6e..ed98cac 100644 (file)
--- a/rocks.c
+++ b/rocks.c
@@ -17,9 +17,11 @@ static struct rock prototypes[NROCKS];
 // timers for rock generation.
 static float rtimers[4];
 
-uint32_t nrocks = I_ROCKS;
+uint32_t nrocks = NORMAL_I_ROCKS;
+uint32_t initial_rocks = NORMAL_I_ROCKS;
+uint32_t final_rocks = NORMAL_F_ROCKS;
 float nrocks_timer = 0;
-float nrocks_inc_ticks = 2*60*20/(F_ROCKS-I_ROCKS);
+float nrocks_inc_ticks = 2*60*20/(NORMAL_F_ROCKS-NORMAL_I_ROCKS);
 
 // constants for rock generation.
 #define KH (32*20)  // 32 s for a speed=1 rock to cross the screen horizontally.
@@ -30,7 +32,8 @@ float nrocks_inc_ticks = 2*60*20/(F_ROCKS-I_ROCKS);
 void
 reset_rocks(void)
 {
-       nrocks = I_ROCKS;
+       nrocks = initial_rocks;
+       nrocks_inc_ticks = 2*60*20/(final_rocks-initial_rocks);
        nrocks_timer = 0;
 }
 
@@ -45,13 +48,14 @@ load_rocks(void)
        for(i=0; i<NROCKS; i++) {
                snprintf(a, ROCK_LEN, "sprites/rock%02d.png", i);
                load_sprite(SPRITE(&prototypes[i]), a);
-               prototypes[i].sprite_type = ROCK_SPRITE;
+               prototypes[i].sprite_type = ROCK;
+               prototypes[i].flags = MOVE|DRAW|COLLIDE;
        }
 
        memset(rocks, 0, MAXROCKS*sizeof(struct rock));
 
        for(i=1; i<MAXROCKS; i++) rocks[i].next = &rocks[i-1];
-       free_sprites[ROCK_SPRITE] = SPRITE(&rocks[MAXROCKS-1]);
+       free_sprites[ROCK] = SPRITE(&rocks[MAXROCKS-1]);
 
        reset_rocks();
 }
@@ -133,7 +137,7 @@ new_rocks(void)
        float rmin[4];
        float rmax[4];
 
-       if(nrocks < F_ROCKS) {
+       if(nrocks < final_rocks) {
                nrocks_timer += t_frame;
                if(nrocks_timer >= nrocks_inc_ticks) {
                        nrocks_timer -= nrocks_inc_ticks;
@@ -150,8 +154,8 @@ new_rocks(void)
        for(i=0; i<4; i++) {
                while(rtimers[i] >= 1) {
                        rtimers[i] -= 1;
-                       if(!free_sprites[ROCK_SPRITE]) return;  // sorry, we ran out of rocks!
-                       r = (struct rock *) remove_sprite(&free_sprites[ROCK_SPRITE]);
+                       if(!free_sprites[ROCK]) return;  // sorry, we ran out of rocks!
+                       r = (struct rock *) remove_sprite(&free_sprites[ROCK]);
                        type = urnd() % NROCKS;
                        *r = prototypes[type];
                        r->type = type;
@@ -206,7 +210,7 @@ blast_rocks(float x, float y, float radius)
        float dx, dy, n;
 
        for(i=0; i<MAXROCKS; i++) {
-               if(rocks[i].sprite_type == NONE) continue;
+               if(!rocks[i].flags) continue;
                r = SPRITE(&rocks[i]);
                if(r->x <= 0) continue;