]> git.mcshandy.xyz Git - assteroids/commitdiff
getting going on the bombs
authorAynRandDuran <lpj1496@gmail.com>
Tue, 13 Jul 2021 00:08:20 +0000 (20:08 -0400)
committerAynRandDuran <lpj1496@gmail.com>
Tue, 13 Jul 2021 00:08:20 +0000 (20:08 -0400)
assteroids.h
game.cpp

index 096e8b037687830674fd3191ca3e2b4a000cfb9a..28286950ee7d1d2cc404a669f9af8854b27e9f51 100644 (file)
@@ -55,5 +55,9 @@ void init_shield();
 void draw_shield_pickup(); //explicitly, the powerup
 void enable_shield();
 void disable_shield();
+
+Vector4 bomb_proj;
+void launch_bomb();
+void update_bomb();
 #endif //__ass
 
index 4d4d1e881a1c8310de5e59a2e27b42ef151eebc1..3a7956f95adcb218d28636c7de28a7bda8d6c72b 100644 (file)
--- a/game.cpp
+++ b/game.cpp
@@ -9,8 +9,6 @@ Vector2 flatten(Vector4 pV){
     return stan;
 }
 
-
-
 Vector4 translate(Vector4 v1, Vector4 v2) {
     Vector4 translation = {v1.x+v2.x, v1.y+v2.y, v1.y+v2.y, v1.z+v2.z};
     return translation;
@@ -28,6 +26,7 @@ void init_ship(){
     nose.z = 270;
     port.z = 55;
     starboard.z = 125;
+    active_powerups = 0;
     
     nose.x = 0; nose.y = -15;
     port.x = -10; port.y = 15;
@@ -42,6 +41,7 @@ void init_ship(){
     memset(&shotgun_box, 0, sizeof(Vector4));
     memset(dead_astr, 0, sizeof(Vector4) * SHIP_DEBRIS * MAX_ASTEROIDS);
     memset(&shield_pickup, 0, sizeof(Vector4));
+    memset(&bomb_proj, 0, sizeof(Vector4));
 }
 
 void die(){
@@ -208,6 +208,10 @@ int main(void) {
             init_ship();
             spin_ship(0);
         }
+        if(IsKeyPressed('A') && active_powerups & BOMB) {
+            active_powerups ^= BOMB;
+            launch_bomb();
+        }
 
         if(!onscreen(flatten(center)) && ship_alive)
             die();
@@ -230,10 +234,18 @@ int main(void) {
                 if(shield_hp <= 0)
                     disable_shield();
             }
+            if(bomb_proj.w != 0)
+                update_bomb();
             if(!throttle) {
                 DrawText("KILL TO LIVE", (scrW/2)-(MeasureText("KILL TO LIVE", 64)/2), (scrH/2)-128, 64, RED);
                 DrawText("LAUNCH TO START", (scrW/2)-(MeasureText("LAUNCH TO START", 32)/2), (scrH/2)+64, 32, RED);
             }
+            if(score%5 == 0 && score > 0) {
+                //Bomb unlocked
+                active_powerups |= BOMB;
+            }
+            if(active_powerups & BOMB) 
+                DrawCircleSectorLines(flatten(translate(nose, center)), 4.0f, 0, 360, 360, RED);
         } else if(!(active_powerups & GOD)) {
             DrawText("YOU DIED", (scrW/2)-(MeasureText("YOU DIED", 64)/2), (scrH/2)-64, 64, RED);
             DrawText("FUCK YOU", (scrW/2)-(MeasureText("FUCK YOU", 16)/2), (scrH/2)-8, 16, RED);
@@ -371,3 +383,17 @@ void draw_shotgun() {
     DrawLineStrip(s_bot_box, 4, WHITE);
     DrawText("S", shotgun_box.x-6, shotgun_box.y-8, 20, GOLD);
 }
+
+void launch_bomb() {
+    bomb_proj.x = flatten(translate(nose, center)).x;
+    bomb_proj.y = flatten(translate(nose, center)).y;
+    bomb_proj.z = nose.z; 
+    bomb_proj.w = 16;
+}
+
+void update_bomb() {
+    bomb_proj.x += cos(bomb_proj.z * (PI/180)) *6;
+    bomb_proj.y += sin(bomb_proj.z * (PI/180)) *6;
+    DrawPolyLines(flatten(bomb_proj), 16, bomb_proj.w, 0, RED);
+
+}