X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=ad3ab56930e833f72170b39de65a98959d18b2a1;hp=4801df76373a811039e637e7b242ff78fdd157b8;hb=2bea0659b8edff14f1554d2540780f54ccdc21c9;hpb=5b505719142e9a18b0b7fd025a13e64d207d1c3a diff --git a/main.c b/main.c index 4801df7..ad3ab56 100644 --- a/main.c +++ b/main.c @@ -19,11 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#undef DEBUG +#ifdef DEBUG +#include "debug.h" +#endif #include "config.h" #include "file.h" #include "score.h" +#include "shape.h" #include "sound.h" #include @@ -50,6 +53,7 @@ struct rock_struct { int dead; // has been blown out of the way // to make room for a new ship appearing. SDL_Surface *image; + struct shape *shape; int type_number; }; struct black_point_struct { @@ -92,9 +96,10 @@ SDL_Surface *surf_ship, // Spaceship element *surf_life, // Indicator of number of ships remaining *surf_rock[NROCKS], // THE ROCKS - *surf_deadrock[NROCKS], // THE DEAD ROCKS *surf_font_big; // The big font +struct shape rock_shapes[NROCKS]; + SFont_Font *g_font; // Structure global variables @@ -108,6 +113,7 @@ struct spacedot sdot[MAXSPACEDOTS]; char topline[1024]; char *initerror = ""; +struct shape shipshape; float shipx,shipy = 240.0; // X position, 0..XSIZE float shipdx,shipdy; // Change in X position per tick. float rockrate,rockspeed; @@ -215,7 +221,7 @@ makebangdots(int xbang, int ybang, int dx, int dy, SDL_Surface *s, int power) { for(x = 0; xw; x++) { for(y = 0; yh; y++) { c = rawpixel[s->pitch/2*y + x]; - if(c && c != SDL_MapRGB(s->format,0,255,0)) { + if(c && c != s->format->colorkey) { theta = rnd()*M_PI*2; @@ -466,6 +472,7 @@ drawdots(SDL_Surface *s) { SDL_UnlockSurface(s); } + char a[MAX_PATH_LEN]; int init(int fullscreen) { @@ -537,6 +544,7 @@ init(int fullscreen) { // Load the spaceship graphic. NULLERROR(temp = IMG_Load(add_path("sprites/ship.png"))); NULLERROR(surf_ship = SDL_DisplayFormat(temp)); + get_shape(surf_ship, &shipshape); // Load the life indicator (small ship) graphic. NULLERROR(temp = IMG_Load(add_path("indicators/life.png"))); @@ -562,15 +570,11 @@ init(int fullscreen) { // Load all our lovely rocks for(i = 0; ipixels; // Check that the black points on the ship are @@ -743,6 +755,7 @@ draw() { } } SDL_UnlockSurface(surf_screen); + */ } // Draw all the little ships @@ -834,13 +847,32 @@ gameloop() { } } else { if(state == DEAD_PAUSE) { - float blast_radius = BLAST_RADIUS * state_timeout / 20.0; + float blast_radius; + int fixonly; + + if(state_timeout < DEAD_PAUSE_LENGTH - 20.0) { + blast_radius = BLAST_RADIUS * 1.3; + fixonly = 1; + } else { + blast_radius = BLAST_RADIUS * (DEAD_PAUSE_LENGTH - state_timeout) / 20.0; + fixonly = 0; + } + if(shipx < 60) shipx = 60; for(i = 0; i 3)) { + continue; + } + dx = rock[i].x - shipx; dy = rock[i].y - shipy; + n = sqrt(dx*dx + dy*dy); if(n < blast_radius) { n *= 20; @@ -864,6 +896,7 @@ gameloop() { rockptr->dy = rnd()-0.5; rockptr->type_number = random() % NROCKS; rockptr->image = surf_rock[rockptr->type_number];// [random()%NROCKS]; + rockptr->shape = &rock_shapes[rockptr->type_number]; rockptr->active = 1; rockptr->y = rnd()*(YSIZE + rockptr->image->h); } @@ -946,7 +979,7 @@ gameloop() { } else { state = DEAD_PAUSE; - state_timeout = 20.0; + state_timeout = DEAD_PAUSE_LENGTH; shipdx = 0; shipdy = 0; } @@ -1002,18 +1035,6 @@ gameloop() { if(keystate[SDLK_p] | keystate[SDLK_s]) { if(!pausedown) { paused = !paused; - if(paused) { - SDL_Rect src,dest; - src.w = surf_b_variations->w; - src.h = surf_b_variations->h; - dest.w = src.w; - dest.h = src.h; - dest.x = (XSIZE-src.w)/2; - dest.y = (YSIZE-src.h)/2; - SDL_BlitSurface(surf_b_variations,&src,surf_screen,&dest); - // Update the surface - SDL_Flip(surf_screen); - } pausedown = 1; } } else {