X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=main.c;h=5724a1af6f2c27ca7e06ff612e3abe14e094f268;hp=489c35290673746a5297ed7e0dec3a6bf839f2f2;hb=7a05bb4e3cd9cfa9d949e26ee6c0b447d687179e;hpb=fac9f096e69b8e1594a90796ec8dcf222fc1b6e3 diff --git a/main.c b/main.c index 489c352..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; @@ -134,6 +136,7 @@ float xvel,yvel; // Change in X position per tick. float rockrate,rockspeed; float movementrate; float yscroll; +float scrollvel; int nships,score,initticks,ticks_since_last, last_ticks; int gameover; @@ -1001,15 +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; - 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; + 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; + } + } } @@ -1143,8 +1166,9 @@ int gameloop() { } else { state = DEAD_PAUSE; - state_timeout = 50.0; - + state_timeout = 20.0; + xvel = 0; + yvel = 0; } } @@ -1159,6 +1183,7 @@ int gameloop() { for(i = 0; i