X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=rocks.c;h=19918edb3d143768ec352cf51d8692efb26ff209;hp=2a9c9067b43a349ebbe724a7cf5e5d13adaf7ab1;hb=13f67bd0888b8b4ccec1a1fb5516074423d0ec32;hpb=9f0bc6ef9620912ca42eca9c3f4b6ca10dba35ce diff --git a/rocks.c b/rocks.c index 2a9c906..19918ed 100644 --- a/rocks.c +++ b/rocks.c @@ -24,7 +24,10 @@ struct shape rock_shapes[NROCKS]; // timers for rock generation. float rtimers[4]; -int nrocks; + +uint32_t nrocks; +uint32_t nrocks_timer; +uint32_t nrocks_inc_ticks = 2*60*1000/(F_ROCKS-I_ROCKS); // constants for rock generation. #define KH 32.0 // 32 s for a speed=1 rock to cross the screen horizontally. @@ -50,7 +53,6 @@ init_rocks(void) NULLERROR(surf_rock[i] = SDL_DisplayFormat(temp)); get_shape(surf_rock[i], &rock_shapes[i]); } - nrocks = 41; return 0; } @@ -60,6 +62,8 @@ reset_rocks(void) int i; for(i = 0; i= nrocks_inc_ticks) { + nrocks_timer -= nrocks_inc_ticks; + nrocks++; + } + } rock_timer_increments(ti); @@ -143,16 +154,8 @@ new_rocks(void) break; } - j=0; - do { - rockptr->dx = RDX*crnd(); - rockptr->dy = RDY*crnd(); - x = (rockptr->dx-screendx)*gamerate; - y = (rockptr->dy-screendy)*gamerate; - j++; - } while(x < -rockptr->image->w || x >= XSIZE - || y < -rockptr->image->h || y >= YSIZE); - if(j > 1) fprintf(stderr, "had to try %d times.\n", j); + rockptr->dx = RDX*crnd(); + rockptr->dy = RDY*crnd(); rockptr->active = 1; } @@ -224,6 +227,8 @@ blast_rocks(float x, float y, float radius, int onlyslow) int i; float dx, dy, n; + if(onlyslow) return; + for(i = 0; i