From: Joshua Grams Date: Fri, 24 Mar 2006 20:18:28 +0000 (+0000) Subject: Made it easier (I hope) to avoid getting killed twice in a row. X-Git-Tag: 0.4~17 X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=commitdiff_plain;h=3cfde1edc98388c11d4efbbba7c8deaf56c4b1ae;ds=sidebyside Made it easier (I hope) to avoid getting killed twice in a row. We now take the square root of the ship's velocity, instead of just half. This appears to put it nicely in the middle of the hole left by the explosion, whatever speed you are going. Also, you now have control over your ship during the DEAD_PAUSE; so it fades in, and is invulnerable until it becomes fully opaque. Note that the dead pause is still the same length as it was before. --- diff --git a/dust.c b/dust.c index 691649d..3a9f246 100644 --- a/dust.c +++ b/dust.c @@ -30,6 +30,8 @@ void move_dust(void) { int i; + float xscroll = screendx * t_frame; + float yscroll = screendy * t_frame; for(i=0; i= XSIZE || bdot[i].y < 0 || bdot[i].y >= YSIZE) { bdot[i].active = 0; continue; @@ -260,8 +259,8 @@ draw_engine_dots(SDL_Surface *s) { for(i = 0; i= XSIZE @@ -603,19 +602,14 @@ gameloop() { screendx += tmp * t_frame/12; // taper off so we don't hit the barrier abruptly. // (if we would hit in < 2 seconds, adjust to 2 seconds). - if(back_dist + (screendx - SCREENDXMIN)*TO_TICKS(2) < 0) { + if(back_dist + (screendx - SCREENDXMIN)*TO_TICKS(2) < 0) screendx = SCREENDXMIN - (back_dist/TO_TICKS(2)); - } - back_dist += (screendx - SCREENDXMIN)*t_frame; if(opt_max_lead >= 0) back_dist = min(back_dist, opt_max_lead); - xscroll = screendx * t_frame; - yscroll = screendy * t_frame; - // move bang center - bangx += bangdx*t_frame - xscroll; - bangy += bangdy*t_frame - yscroll; + bangx += (bangdx - screendx)*t_frame; + bangy += (bangdy - screendy)*t_frame; move_sprites(); @@ -640,17 +634,19 @@ gameloop() { play_sound(SOUND_BANG); // Play the explosion sound bangx = ship.x; bangy = ship.y; bangdx = ship.dx; bangdy = ship.dy; new_bang_dots(ship.x,ship.y,ship.dx,ship.dy,ship.image); - ship.dx *= 0.5; ship.dy *= 0.5; - if(ship.dx < SCREENDXMIN) ship.dx = SCREENDXMIN; - if(--ship.lives <= 0) { + + if(--ship.lives) { + state = DEAD_PAUSE; + state_timeout = DEAD_PAUSE_LENGTH; + ship.dx = (ship.dx < 0) ? -sqrt(-ship.dx) : sqrt(ship.dx); + ship.dy = (ship.dy < 0) ? -sqrt(-ship.dy) : sqrt(ship.dy); + if(ship.dx < SCREENDXMIN) ship.dx = SCREENDXMIN; + } else { state = GAME_OVER; ship.dx = SCREENDXMIN; ship.dy = 0; state_timeout = 200.0; fadetimer = 0.0; faderate = t_frame; - } else { - state = DEAD_PAUSE; - state_timeout = DEAD_PAUSE_LENGTH; } } @@ -661,6 +657,7 @@ gameloop() { || state == GAME_OVER)) { reset_sprites(); reset_rocks(); + screendx = SCREENDXMIN; screendy = 0; ship.x = XSIZE/2.2; ship.y = YSIZE/2; ship.dx = screendx; ship.dy = screendy;