Library containing the Game Engine

Revision:
9:0f359bc0922f
Parent:
8:bd718162a87c
Child:
10:df8ea4e747e2
--- a/GameEngine.cpp	Wed May 03 13:01:09 2017 +0000
+++ b/GameEngine.cpp	Wed May 03 13:33:23 2017 +0000
@@ -235,6 +235,8 @@
 void GameEngine::CheckPlayerTargetCollision(Gamepad &pad)
     {
         Vector2D t_pos = _t.get_pos();
+        Vector2D tt_pos = _tt.get_pos();
+        Vector2D ttt_pos = _ttt.get_pos();
         Vector2D player_pos = _p.get_pos();
         
          
@@ -244,36 +246,150 @@
         (player_pos.y == t_pos.y + 2) ||
         (player_pos.y == t_pos.y + 3) ||
         (player_pos.y == t_pos.y + 4) ||
-        
-        (player_pos.y +2 == t_pos.y) ||
-        (player_pos.y +2 == t_pos.y + 1) ||
-        (player_pos.y +2 == t_pos.y + 2) ||
-        (player_pos.y +2 == t_pos.y + 3) ||
-        (player_pos.y +2 == t_pos.y + 4)) &&
+        (player_pos.y == t_pos.y + 5) ||
+        (player_pos.y == t_pos.y + 6) ||
+        (player_pos.y == t_pos.y + 7) ||
+        (player_pos.y + 4 == t_pos.y) ||
+        (player_pos.y + 4 == t_pos.y + 1) ||
+        (player_pos.y + 4 == t_pos.y + 2) ||
+        (player_pos.y + 4 == t_pos.y + 3) ||
+        (player_pos.y + 4 == t_pos.y + 4) ||
+        (player_pos.y + 4 == t_pos.y + 5) ||
+        (player_pos.y + 4 == t_pos.y + 6) ||
+        (player_pos.y + 4 == t_pos.y + 7)) &&
         ((player_pos.x == t_pos.x) ||
         (player_pos.x == t_pos.x + 1) ||
         (player_pos.x == t_pos.x + 2) ||
         (player_pos.x == t_pos.x + 3) ||
         (player_pos.x == t_pos.x + 4) ||
-        
-        (player_pos.x +2 == t_pos.x) ||
-        (player_pos.x +2 == t_pos.x + 1) ||
-        (player_pos.x +2 == t_pos.x + 2) ||
-        (player_pos.x +2 == t_pos.x + 3) ||
-        (player_pos.x +2 == t_pos.x + 4))
+        (player_pos.x == t_pos.x + 5) ||
+        (player_pos.x == t_pos.x + 6) ||
+        (player_pos.x == t_pos.x + 7) ||
+        (player_pos.x == t_pos.x + 8) ||
+        (player_pos.x == t_pos.x + 9) ||
+        (player_pos.x == t_pos.x + 10) ||
+        (player_pos.x + 5 == t_pos.x) ||
+        (player_pos.x + 5 == t_pos.x + 1) ||
+        (player_pos.x + 5 == t_pos.x + 2) ||
+        (player_pos.x + 5 == t_pos.x + 3) ||
+        (player_pos.x + 5 == t_pos.x + 4) ||
+        (player_pos.x + 5 == t_pos.x + 5) ||
+        (player_pos.x + 5 == t_pos.x + 6) ||
+        (player_pos.x + 5 == t_pos.x + 7) ||
+        (player_pos.x + 5 == t_pos.x + 8) ||
+        (player_pos.x + 5 == t_pos.x + 9) ||
+        (player_pos.x + 5 == t_pos.x + 10))
     ) {
         
         //printf("collision working \n");
         // audio feedback
         //pad.tone(1000.0,0.1);
         t_pos.x = rand() % 79;
-        t_pos.y = 20;
+        t_pos.y = 0;
+        printf("hit");
+    }
+    
+    if (
+        ((player_pos.y == tt_pos.y) ||
+        (player_pos.y == tt_pos.y + 1) ||
+        (player_pos.y == tt_pos.y + 2) ||
+        (player_pos.y == tt_pos.y + 3) ||
+        (player_pos.y == tt_pos.y + 4) ||
+        (player_pos.y == tt_pos.y + 5) ||
+        (player_pos.y == tt_pos.y + 6) ||
+        (player_pos.y == tt_pos.y + 7) ||
+        (player_pos.y + 4 == tt_pos.y) ||
+        (player_pos.y + 4 == tt_pos.y + 1) ||
+        (player_pos.y + 4 == tt_pos.y + 2) ||
+        (player_pos.y + 4 == tt_pos.y + 3) ||
+        (player_pos.y + 4 == tt_pos.y + 4) ||
+        (player_pos.y + 4 == tt_pos.y + 5) ||
+        (player_pos.y + 4 == tt_pos.y + 6) ||
+        (player_pos.y + 4 == tt_pos.y + 7)) &&
+        ((player_pos.x == tt_pos.x) ||
+        (player_pos.x == tt_pos.x + 1) ||
+        (player_pos.x == tt_pos.x + 2) ||
+        (player_pos.x == tt_pos.x + 3) ||
+        (player_pos.x == tt_pos.x + 4) ||
+        (player_pos.x == tt_pos.x + 5) ||
+        (player_pos.x == tt_pos.x + 6) ||
+        (player_pos.x == tt_pos.x + 7) ||
+        (player_pos.x == tt_pos.x + 8) ||
+        (player_pos.x == tt_pos.x + 9) ||
+        (player_pos.x == tt_pos.x + 10) ||
+        (player_pos.x + 5 == tt_pos.x) ||
+        (player_pos.x + 5 == tt_pos.x + 1) ||
+        (player_pos.x + 5 == tt_pos.x + 2) ||
+        (player_pos.x + 5 == tt_pos.x + 3) ||
+        (player_pos.x + 5 == tt_pos.x + 4) ||
+        (player_pos.x + 5 == tt_pos.x + 5) ||
+        (player_pos.x + 5 == tt_pos.x + 6) ||
+        (player_pos.x + 5 == tt_pos.x + 7) ||
+        (player_pos.x + 5 == tt_pos.x + 8) ||
+        (player_pos.x + 5 == tt_pos.x + 9) ||
+        (player_pos.x + 5 == tt_pos.x + 10))
+    ) {
         
+        //printf("collision working \n");
+        // audio feedback
+        //pad.tone(1000.0,0.1);
+        tt_pos.x = rand() % 79;
+        tt_pos.y = 0;
+        printf("hit");
+    }
+    
+    if (
+        ((player_pos.y == ttt_pos.y) ||
+        (player_pos.y == ttt_pos.y + 1) ||
+        (player_pos.y == ttt_pos.y + 2) ||
+        (player_pos.y == ttt_pos.y + 3) ||
+        (player_pos.y == ttt_pos.y + 4) ||
+        (player_pos.y == ttt_pos.y + 5) ||
+        (player_pos.y == ttt_pos.y + 6) ||
+        (player_pos.y == ttt_pos.y + 7) ||
+        (player_pos.y + 4 == ttt_pos.y) ||
+        (player_pos.y + 4 == ttt_pos.y + 1) ||
+        (player_pos.y + 4 == ttt_pos.y + 2) ||
+        (player_pos.y + 4 == ttt_pos.y + 3) ||
+        (player_pos.y + 4 == ttt_pos.y + 4) ||
+        (player_pos.y + 4 == ttt_pos.y + 5) ||
+        (player_pos.y + 4 == ttt_pos.y + 6) ||
+        (player_pos.y + 4 == ttt_pos.y + 7)) &&
+        ((player_pos.x == ttt_pos.x) ||
+        (player_pos.x == ttt_pos.x + 1) ||
+        (player_pos.x == ttt_pos.x + 2) ||
+        (player_pos.x == ttt_pos.x + 3) ||
+        (player_pos.x == ttt_pos.x + 4) ||
+        (player_pos.x == ttt_pos.x + 5) ||
+        (player_pos.x == ttt_pos.x + 6) ||
+        (player_pos.x == ttt_pos.x + 7) ||
+        (player_pos.x == ttt_pos.x + 8) ||
+        (player_pos.x == ttt_pos.x + 9) ||
+        (player_pos.x == ttt_pos.x + 10) ||
+        (player_pos.x + 5 == ttt_pos.x) ||
+        (player_pos.x + 5 == ttt_pos.x + 1) ||
+        (player_pos.x + 5 == ttt_pos.x + 2) ||
+        (player_pos.x + 5 == ttt_pos.x + 3) ||
+        (player_pos.x + 5 == ttt_pos.x + 4) ||
+        (player_pos.x + 5 == ttt_pos.x + 5) ||
+        (player_pos.x + 5 == ttt_pos.x + 6) ||
+        (player_pos.x + 5 == ttt_pos.x + 7) ||
+        (player_pos.x + 5 == ttt_pos.x + 8) ||
+        (player_pos.x + 5 == ttt_pos.x + 9) ||
+        (player_pos.x + 5 == ttt_pos.x + 10))
+    ) {
+        
+        //printf("collision working \n");
+        // audio feedback
+        //pad.tone(1000.0,0.1);
+        ttt_pos.x = rand() % 79;
+        ttt_pos.y = 0;
+        printf("hit");
     }
 
     _t.set_pos(t_pos);
-    
-       
+    _tt.set_pos(tt_pos);
+    _ttt.set_pos(ttt_pos);
     }