struct shape shipshape;
float shipx = XSIZE/2, shipy = YSIZE/2; // X position, 0..XSIZE
float shipdx = SCREENDXMIN, shipdy = 0.0; // Change in X position per tick.
struct shape shipshape;
float shipx = XSIZE/2, shipy = YSIZE/2; // X position, 0..XSIZE
float shipdx = SCREENDXMIN, shipdy = 0.0; // Change in X position per tick.
// all movement is based on t_frame.
float t_frame; // length of this frame (in ticks = 1/20th second)
// all movement is based on t_frame.
float t_frame; // length of this frame (in ticks = 1/20th second)
int ms_frame; // length of this frame (milliseconds)
int ms_end; // end of this frame (milliseconds)
float bangx, bangy, bangdx, bangdy;
int nships,score;
int ms_frame; // length of this frame (milliseconds)
int ms_end; // end of this frame (milliseconds)
float bangx, bangy, bangdx, bangdy;
int nships,score;
-new_bang_dots(int xbang, int ybang, int dx, int dy, SDL_Surface *s, int power)
+new_bang_dots(int xbang, int ybang, int dx, int dy, SDL_Surface *s)
- for(x = 0; x<s->w; x++) {
- for(y = 0; y<s->h; y++) {
- c = rawpixel[s->pitch/2*y + x];
- if(c && c != s->format->colorkey) {
-
+ pixel = s->pixels;
+ for(y=0; y<s->h; y++) {
+ for(x = 0; x<s->w; x++) {
+ c = *pixel++;
+ if(c && c != colorkey) {
- bd2++;
- bd2 %= MAXBANGDOTS;
-
- // If the circular buffer is filled, who cares? They've had their chance.
- //if(bd2 == bd1-1) goto exitloop;
+ // Replace the last few bang dots with the pixels from the exploding object
+ if(endcount>0) bdot[bd2].c = c;
rawpixel[(int)(s->pitch/2*(int)(bdot[i].y)) + (int)(bdot[i].x)] = bdot[i].c ? bdot[i].c : heatcolor[(int)(bdot[i].life*3)];
bdot[i].life -= bdot[i].decay;
bdot[i].x += bdot[i].dx*t_frame - xscroll;
bdot[i].y += bdot[i].dy*t_frame - yscroll;
rawpixel[(int)(s->pitch/2*(int)(bdot[i].y)) + (int)(bdot[i].x)] = bdot[i].c ? bdot[i].c : heatcolor[(int)(bdot[i].life*3)];
bdot[i].life -= bdot[i].decay;
bdot[i].x += bdot[i].dx*t_frame - xscroll;
bdot[i].y += bdot[i].dy*t_frame - yscroll;
dest.x = shipx;
dest.y = shipy;
SDL_BlitSurface(surf_ship,NULL,surf_screen,&dest);
dest.x = shipx;
dest.y = shipy;
SDL_BlitSurface(surf_ship,NULL,surf_screen,&dest);
- if(state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER)
- for(i = 0; i<nships-1; i++) {
- dest.x = (i + 1)*(surf_life->w + 10);
- dest.y = 20;
- SDL_BlitSurface(surf_life, NULL, surf_screen, &dest);
+ if(state == GAMEPLAY || state == DEAD_PAUSE || state == GAME_OVER) {
+ for(i = 0; i<nships-1; i++) {
+ dest.x = (i + 1)*(surf_life->w + 10);
+ dest.y = 20;
+ SDL_BlitSurface(surf_life, NULL, surf_screen, &dest);
+ }
if(ms_frame>200 || ms_frame<0) {
// We won't run at all below 5 frames per second.
// This also happens if we were paused, grr.
if(ms_frame>200 || ms_frame<0) {
// We won't run at all below 5 frames per second.
// This also happens if we were paused, grr.
screendy += tmp * t_frame/12;
tmp = (shipx-XSCROLLTO)/25 + (shipdx-screendx);
screendx += tmp * t_frame/12;
screendy += tmp * t_frame/12;
tmp = (shipx-XSCROLLTO)/25 + (shipdx-screendx);
screendx += tmp * t_frame/12;
if(back_dist + (screendx - SCREENDXMIN)*TO_TICKS(2) < 0) {
screendx = SCREENDXMIN - (back_dist/TO_TICKS(2));
}
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);
back_dist += (screendx - SCREENDXMIN)*t_frame;
if(opt_max_lead >= 0) back_dist = min(back_dist, opt_max_lead);
// Died
play_sound(SOUND_BANG); // Play the explosion sound
bangx = shipx; bangy = shipy; bangdx = shipdx; bangdy = shipdy;
// Died
play_sound(SOUND_BANG); // Play the explosion sound
bangx = shipx; bangy = shipy; bangdx = shipdx; bangdy = shipdy;
- new_bang_dots(shipx,shipy,shipdx,shipdy,surf_ship,30);
+ new_bang_dots(shipx,shipy,shipdx,shipdy,surf_ship);
- if(!gameover) {
-
- if(!paused) {
- if(keystate[SDLK_LEFT] | keystate[SDLK_h]) { shipdx -= 1.5*t_frame; jets |= 1<<0;}
- if(keystate[SDLK_DOWN] | keystate[SDLK_t]) { shipdy += 1.5*t_frame; jets |= 1<<1;}
- if(keystate[SDLK_RIGHT] | keystate[SDLK_n]) { shipdx += 1.5*t_frame; jets |= 1<<2;}
- if(keystate[SDLK_UP] | keystate[SDLK_c]) { shipdy -= 1.5*t_frame; jets |= 1<<3;}
- if(keystate[SDLK_3]) { SDL_SaveBMP(surf_screen, "snapshot.bmp"); }
- }
+ if(!paused) {
+ if(keystate[SDLK_LEFT] | keystate[SDLK_h]) { shipdx -= 1.5*t_frame; jets |= 1<<0;}
+ if(keystate[SDLK_DOWN] | keystate[SDLK_t]) { shipdy += 1.5*t_frame; jets |= 1<<1;}
+ if(keystate[SDLK_RIGHT] | keystate[SDLK_n]) { shipdx += 1.5*t_frame; jets |= 1<<2;}
+ if(keystate[SDLK_UP] | keystate[SDLK_c]) { shipdy -= 1.5*t_frame; jets |= 1<<3;}
+ if(keystate[SDLK_3]) { SDL_SaveBMP(surf_screen, "snapshot.bmp"); }
+ }