- yscroll = yship - (YSIZE / 2);
- yscroll /= -15;
- yscroll = yscroll*movementrate;
- yship += yscroll;
-
- // Move all the rocks
- for(i = 0; i<MAXROCKS; i++) if(rock[i].active) {
- rock[i].x += rock[i].xvel*movementrate;
- rock[i].y += rock[i].yvel*movementrate + yscroll;
- if(rock[i].y > YSIZE) {
- rock[i].y -= YSIZE;
- rock[i].y -= rock[i].image->w;
- } else if(rock[i].y < -rock[i].image->w) {
- rock[i].y += YSIZE;
- rock[i].y += rock[i].image->w;
- }
- if(rock[i].x<-32.0)
- rock[i].active = 0;
- }
-
-
- // BOUNCE X
- if(xship<0 || xship>XSIZE-surf_ship->w) {
- // BOUNCE from left and right wall
- xship -= xvel*movementrate;
- xvel *= -0.99;
- }
-
- // BOUNCE Y
- if(yship<0 || yship>YSIZE-surf_ship->h) {
- // BOUNCE from top and bottom wall
- yship -= yvel;
- yvel *= -0.99;
- }
-
-
- if(draw() && state == GAMEPLAY) {
- if(oss_sound_flag) {
- // Play the explosion sound
- play_sound(0);
- }
- makebangdots(xship,yship,xvel,yvel,surf_ship,30);
- if(--nships <= 0) {
- gameover = 1;
+ tmp = (ship.y+ship.h/2+ship.dy*t_frame-YSCROLLTO)/25 + (ship.dy-screendy);
+ screendy += tmp * t_frame/12;
+ tmp = (ship.x+ship.w/2+ship.dx*t_frame-XSCROLLTO)/25 + (ship.dx-screendx);
+ 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)
+ 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);
+
+ // move bang center
+ bangx += (bangdx - screendx)*t_frame;
+ bangy += (bangdy - screendy)*t_frame;
+
+ move_sprites(t_frame);
+ move_engine_dots(t_frame);
+ move_bang_dots(t_frame);
+ move_dust(t_frame);
+
+ // BOUNCE off left or right edge of screen
+ if(ship.x < 0 || ship.x+ship.w > XSIZE) {
+ ship.x -= (ship.dx-screendx)*t_frame;
+ ship.dx = screendx - (ship.dx-screendx)*opt_bounciness;
+ }
+
+ // BOUNCE off top or bottom of screen
+ if(ship.y < 0 || ship.y+ship.h > YSIZE) {
+ ship.y -= (ship.dy-screendy)*t_frame;
+ ship.dy = screendy - (ship.dy-screendy)*opt_bounciness;
+ }
+
+ new_rocks(t_frame);
+ new_engine_dots(t_frame);
+
+ draw();
+
+ if(state == GAMEPLAY && bang) {
+ // Died
+ bang = false;
+ 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);
+
+ 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 {