X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=5724a1af6f2c27ca7e06ff612e3abe14e094f268;hp=9919777b6ac4e7d564053e97538e33771bf6b890;hb=7a05bb4e3cd9cfa9d949e26ee6c0b447d687179e;hpb=0b24ad4c75e0b324775bcb61e051d3031b6e54ef diff --git a/main.c b/main.c index 9919777..5724a1a 100644 --- a/main.c +++ b/main.c @@ -54,6 +54,8 @@ struct rock_struct { // soon as it isn't we BLOW UP float x,y,xvel,yvel; int active; + int dead; // has been blown out of the way + // to make room for a new ship appearing. SDL_Surface *image; int type_number; float heat; @@ -1002,10 +1004,7 @@ int gameloop() { // Create a new ship and start all over again state = GAMEPLAY; play_tune(1); - xship = 10; - yship = YSIZE/2; - xvel = 3; - yvel = 0; + xship -= 50; break; case GAME_OVER: state = HIGH_SCORE_ENTRY; @@ -1052,18 +1051,19 @@ int gameloop() { } } else { if(state == DEAD_PAUSE) { - float blast_radius = START_RAD * state_timeout / 50.0; + float blast_radius = START_RAD * state_timeout / 20.0; + if(xship < 60) xship = 60; for(i = 0; i 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; - if(rock[i].xvel > 0) { - if(rock[i].y < 0 || rock[i].y > YSIZE) rock[i].active = 0; - if(rock[i].x > XSIZE) rock[i].active = 0; + 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 > 0) || (rock[i].y < -rock[i].image->h && rock[i].y < 0)) { + if(rock[i].dead) { + rock[i].dead = 0; + rock[i].active = 0; + } else { + // wrap + rock[i].y = (YSIZE - rock[i].image->h) - rock[i].y; + rock[i].y += (rock[i].yvel*movementrate + yscroll) * 2; + } + } + if(rock[i].x < -32.0 || rock[i].x > XSIZE + 32.0) { + rock[i].active = 0; + rock[i].dead = 0; + } } } @@ -1162,7 +1166,9 @@ int gameloop() { } else { state = DEAD_PAUSE; - state_timeout = 50.0; + state_timeout = 20.0; + xvel = 0; + yvel = 0; } } @@ -1177,6 +1183,7 @@ int gameloop() { for(i = 0; i