]> git.mcshandy.xyz Git - assteroids/commitdiff
slower rate of fire
authorAynRandDuran <lpj1496@gmail.com>
Mon, 5 Jul 2021 17:16:16 +0000 (13:16 -0400)
committerAynRandDuran <lpj1496@gmail.com>
Mon, 5 Jul 2021 17:16:16 +0000 (13:16 -0400)
assteroids.h
game.cpp

index 22cf9455fd34590cec849cdf7e057305513b2e1f..f9c3547e402bef7184206d8b331195a5a57f2605 100644 (file)
@@ -17,6 +17,7 @@ Vector4* bullets;
 const int MAX_BULLETS = 32;
 unsigned int score = 0;
 Rectangle screenspace = {-200, -200, scrW+200, scrH+200};
+time_t last_fire = 0;
 
 // x/y pos, z heading, w size/life
 Vector4* asteroids;
index 56afcccb3e117c2aa754648e90c6c86b3d2d192a..ed7702675b23373ca564e035340ec9ff0dc0e11c 100644 (file)
--- a/game.cpp
+++ b/game.cpp
@@ -46,7 +46,7 @@ void die(){
             continue;
         dead_ship[i].x = center.x; dead_ship[i].y = center.y;
         dead_ship[i].z = (360/SHIP_DEBRIS) * (i + 1);
-        dead_ship[i].w = 4;
+        dead_ship[i].w = 6;
     }
     
 }
@@ -73,11 +73,12 @@ void update_v4(Vector4* origin, Vector4* v_body, int speed){
 void shoot(){
     for(int i = 0; i < MAX_BULLETS; i++){
         // find available bullet
-        if(bullets[i].w == 0) {
+        if(bullets[i].w == 0 && time(NULL) > last_fire) {
             bullets[i].x = center.x;
             bullets[i].y = center.y;
             bullets[i].z = nose.z;
             bullets[i].w = 1; 
+            time(&last_fire);
             break;
         }
     }