// 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.
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)
char a[ROCK_LEN];
for(i=0; i<NROCKS; i++) {
- snprintf(a, ROCK_LEN, "sprites/rock%02d.png", i);
+ snprintf(a, ROCK_LEN, "rock%02d.png", i);
load_sprite(SPRITE(&prototypes[i]), a);
prototypes[i].sprite_type = ROCK;
prototypes[i].flags = MOVE|DRAW|COLLIDE;
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;
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();
int i;
for(i=0; i<MAXROCKS; i++) draw_sprite(SPRITE(&rocks[i]));
}
-
-void
-blast_rocks(float x, float y, float radius)
-{
- int i;
- Sprite *r;
- float dx, dy, n;
-
- for(i=0; i<MAXROCKS; i++) {
- if(!rocks[i].flags) continue;
- r = SPRITE(&rocks[i]);
- if(r->x <= 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;
- }
- }
-}