Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Files at this revision

API Documentation at this revision

Comitter:
el17sm
Date:
Thu Apr 25 04:40:30 2019 +0000
Parent:
15:44d5cc33d389
Commit message:
the true updated headless only functional game

Changed in this revision

Entity/Entity.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Headless/Headless.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Entity/Entity.cpp	Wed Apr 24 06:28:14 2019 +0000
+++ b/Entity/Entity.cpp	Thu Apr 25 04:40:30 2019 +0000
@@ -11,7 +11,7 @@
         position.y = prev_pos.y;
     }
 }
-void Entity::update_prev_pos(){prev_pos = position;};
+void Entity::update_prev_pos(){prev_pos = position;}
 
 bool Entity::matrix_collision_test(float pos_x, float pos_y, int map_no){
     for (int j = pos_y; j < (int)pos_y + hitbox.height; j++){
--- a/Entity/Headless/Headless.cpp	Wed Apr 24 06:28:14 2019 +0000
+++ b/Entity/Headless/Headless.cpp	Thu Apr 25 04:40:30 2019 +0000
@@ -43,6 +43,10 @@
         face = 3;
     }
     
+    // wall collision
+    undo_move_x(matrix_collision_test(position.x, prev_pos.y, 0));
+    undo_move_y(matrix_collision_test(prev_pos.x, position.y, 0));
+    
     if (frame.number < frame.max){
         frame.count++;
     }
--- a/main.cpp	Wed Apr 24 06:28:14 2019 +0000
+++ b/main.cpp	Thu Apr 25 04:40:30 2019 +0000
@@ -103,24 +103,27 @@
                         goto gameover;
                     }
                 }
-            };
+            }
             for (int i = 0; i < bullets_max; i++){
                 if (player.valid_bullets[i]){
-                    for (int j = 0; j < no_of_enemies; j++){
-                        if (valid_enemies[j]){
-                            if(entity_collision(*player.bullets_array[i], *enemies[j])){
-                                enemies[j]->take_damage(player.get_attack());
-                                player.valid_bullets[i] = false;
-                                player.bullets_array[i]->~Bullets;
+                    if (player.bullets_array[i]->out_of_bounds_check()){
+                            player.valid_bullets[i] = false;
+                            player.bullets_array[i]->~Bullets;
+                    }
+                    else {
+                        for (int j = 0; j < no_of_enemies; j++){
+                            if (valid_enemies[j]){
+                                if(entity_collision(*player.bullets_array[i], *enemies[j])){
+                                    enemies[j]->take_damage(player.get_attack());
+                                    player.valid_bullets[i] = false;
+                                    player.bullets_array[i]->~Bullets;
+                                    break;
+                                }
                             }
                         }
-                        if (player.bullets_array[i]->out_of_bounds_check()){
-                            player.valid_bullets[i] = false;
-                            player.bullets_array[i]->~Bullets;
-                        }
-                    };
+                    }
                 }
-            };
+            }
             
             // Player Movement
             Vector2D mapped_coord = gamepad.get_mapped_coord();