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

Dependencies:   mbed MotionSensor

Revision:
57:1c12361b6e3d
Parent:
51:4d0cd75e7ed3
--- a/Entity/Entity.cpp	Thu May 09 08:42:52 2019 +0000
+++ b/Entity/Entity.cpp	Thu May 09 09:50:19 2019 +0000
@@ -4,24 +4,24 @@
 void Entity::undo_move_x(bool condition)
 {
     if (condition) {
-        position.x = prev_pos.x;
+        _position.x = _prev_pos.x;
     }
 }
 void Entity::undo_move_y(bool condition)
 {
     if (condition) {
-        position.y = prev_pos.y;
+        _position.y = _prev_pos.y;
     }
 }
 void Entity::update_prev_pos()
 {
-    prev_pos = position;
+    _prev_pos = _position;
 }
 
 bool Entity::entity_to_map_collision_test(float pos_x, float pos_y, char * two_d_map, bool * doorways)    // Returns true if the entity clashes a wall
 {      
-    for (int j = pos_y; j < (int)pos_y + hitbox.height; j++) {
-        for(int i = pos_x; i < (int)pos_x + hitbox.width; i++) {
+    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>=screen_height) || (i>=screen_width) || (j<0) || (i<0)) {} // To allow movement towards outside of the map
             else if (*((two_d_map+j*screen_width)+i) == 1) {  // if entity clashes the 2d map
                 return true;
@@ -31,10 +31,10 @@
             else if ( !(*(doorways)) && (pos_y <= 10) ) {
                 return true;
             }
-            else if ( !(*(doorways+1)) && (pos_x + hitbox.width - 1 >= 81) ) {
+            else if ( !(*(doorways+1)) && (pos_x + _hitbox.width - 1 >= 81) ) {
                 return true;
             }
-            else if ( !(*(doorways+2)) && (pos_y + hitbox.height - 1 >= 45) ) {
+            else if ( !(*(doorways+2)) && (pos_y + _hitbox.height - 1 >= 45) ) {
                 return true;
             }
             else if ( !(*(doorways+3)) && (pos_x <= 3) ) {
@@ -49,17 +49,17 @@
 
 void Entity::set_position(float x, float y)
 {
-    position.x = x;
-    position.y = y;
+    _position.x = x;
+    _position.y = y;
 }
 
 void Entity::position_add_x(float change_x)
 {
-    position.x += change_x;
+    _position.x += change_x;
 }
 void Entity::position_add_y(float change_y)
 {
-    position.y += change_y;
+    _position.y += change_y;
 }
 
 // Accessors
@@ -69,57 +69,57 @@
 }
 int Entity::get_hitbox_width()
 {
-    return hitbox.width;
+    return _hitbox.width;
 }
 int Entity::get_hitbox_height()
 {
-    return hitbox.height;
+    return _hitbox.height;
 }
 int Entity::get_face()
 {
-    return face;
+    return _face;
 }
 int Entity::get_sprite_width()
 {
-    return sprite_size.width;
+    return _sprite_size.width;
 }
 int Entity::get_sprite_height()
 {
-    return sprite_size.height;
+    return _sprite_size.height;
 }
 int Entity::get_offset_x()
 {
-    return sprite_size.offset_x;
+    return _sprite_size.offset_x;
 }
 int Entity::get_offset_y()
 {
-    return sprite_size.offset_y;
+    return _sprite_size.offset_y;
 }
 int Entity::get_pos_x()
 {
-    return position.x;
+    return _position.x;
 }
 int Entity::get_pos_y()
 {
-    return position.y;
+    return _position.y;
 }
 int Entity::get_prev_pos_x()
 {
-    return prev_pos.x;
+    return _prev_pos.x;
 }
 int Entity::get_prev_pos_y()
 {
-    return prev_pos.y;
+    return _prev_pos.y;
 }
 int Entity::get_attack()
 {
-    return attack;
+    return _attack;
 }
 int Entity::get_hp()
 {
-    return hp;
+    return _hp;
 }
 float Entity::get_velocity()
 {
-    return velocity;
+    return _velocity;
 }
\ No newline at end of file