X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=rocks.c;h=ff8f8f96a1a0aaa9f89bf04539b745e9f00fae31;hp=7285d3beb85d2f3dab9b2cb0a3ffb059a1d384de;hb=HEAD;hpb=0978da8f14d855eecae9882b559d6e8b0533e78e diff --git a/rocks.c b/rocks.c index 7285d3b..ff8f8f9 100644 --- a/rocks.c +++ b/rocks.c @@ -4,7 +4,7 @@ #include #include "common.h" -#include "config.h" +#include "vorconfig.h" #include "file.h" #include "globals.h" #include "mt.h" @@ -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,11 +32,12 @@ 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; } -#define ROCK_LEN sizeof("sprites/rockXX.png") +#define ROCK_LEN sizeof("rockXX.png") void load_rocks(void) @@ -43,10 +46,10 @@ load_rocks(void) char a[ROCK_LEN]; for(i=0; i= nrocks_inc_ticks) { nrocks_timer -= nrocks_inc_ticks; @@ -156,6 +159,7 @@ new_rocks(void) type = urnd() % NROCKS; *r = prototypes[type]; r->type = type; + r->life = r->area * 300; switch(i) { case RIGHT: r->x = XSIZE; @@ -172,14 +176,14 @@ new_rocks(void) r->dy = RDY*crnd(); break; case BOTTOM: - r->x = frnd()*(XSIZE + r->image->w); + r->x = (frnd()*(XSIZE + r->image->w)) - r->image->w; r->y = YSIZE; r->dx = RDX*crnd(); r->dy = -weighted_rnd_range(rmin[i], rmax[i]) + screendy; break; case TOP: - r->x = frnd()*(XSIZE + r->image->w); + r->x = (frnd() * (XSIZE + r->image->w)) - r->image->w; r->y = -r->image->h; r->dx = RDX*crnd(); @@ -198,28 +202,3 @@ draw_rocks(void) int i; for(i=0; ix <= 0) continue; - - dx = r->x - x; - dy = r->y - y; - - n = sqrt(dx*dx + dy*dy); - if(n < radius) { - n *= 15; - r->dx += 54.0*dx/n; - r->dy += 54.0*dy/n; - r->flags &= ~COLLIDE_FLAG; - } - } -}