From bfc1ca0ef9d6baf4dc4318f387ed606b6daa771e Mon Sep 17 00:00:00 2001 From: AynRandDuran Date: Mon, 5 Jul 2021 13:16:16 -0400 Subject: [PATCH] slower rate of fire --- assteroids.h | 1 + game.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assteroids.h b/assteroids.h index 22cf945..f9c3547 100644 --- a/assteroids.h +++ b/assteroids.h @@ -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; diff --git a/game.cpp b/game.cpp index 56afccc..ed77026 100644 --- 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; } } -- 2.49.0