A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.

Dependencies:   mbed MotionSensor

Revision:
13:d04a6caba40d
Parent:
11:63e54f6e7939
Child:
14:3361879490b2
--- a/Entity/Entity.cpp	Tue Apr 23 22:59:12 2019 +0000
+++ b/Entity/Entity.cpp	Wed Apr 24 02:33:33 2019 +0000
@@ -1,8 +1,35 @@
 #include "Entity.h"
 
-// constructors
+// functions
+void Entity::undo_move_x(bool status_x){
+    if (status_x){
+        position.x = prev_pos.x;
+    }
+}
+void Entity::undo_move_y(bool status_y){
+    if (status_y){
+        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++){
+        for(int i = pos_x; i < (int)pos_x + hitbox.width; i++){
+            if ((j>=48) || (i>=84) || (j<0) || (i<0)) {}
+            else if ((level_map[0][j][i] == 1)) {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+void Entity::take_damage(int damage){
+    hp -= damage;
+}
+
+// mutators
 
 // accessors
 bool Entity::get_moving(){return moving;}