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

Dependencies:   mbed MotionSensor

Revision:
10:1a3499f6b583
Child:
11:63e54f6e7939
diff -r 304079450898 -r 1a3499f6b583 Entity/Entity.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Entity.h	Sun Apr 21 23:23:35 2019 +0000
@@ -0,0 +1,66 @@
+#ifndef ENTITY_H
+#define ENTITY_H
+#include "sprites.h"
+#include "math.h"
+
+class Entity
+{   
+    protected:
+        bool moving;
+        struct Hitbox {
+            int width;
+            int height;
+        };
+        Hitbox hitbox;
+        struct SpriteSize {
+            int width;
+            int height;
+            // Top-left corner of sprite is offset_x 
+            // to the right of top-left corner of hitbox
+            int offset_x;
+            // Top-left corner of sprite is offset_y 
+            // above of top-left corner of hitbox
+            int offset_y;
+        };
+        SpriteSize sprite_size;
+        struct Position {
+            float x;
+            float y;
+        };
+        Position position;
+        int hp;
+        int face;
+        
+    public:
+        // Functions
+        virtual void move(float, float) = 0;
+        
+        bool 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;
+        }
+        
+        virtual void chkdmg() = 0;
+        
+        // Accessors
+        bool get_moving();
+        int get_hitbox_width();
+        int get_hitbox_height();
+        int get_face();
+        int get_sprite_width();
+        int get_sprite_height();
+        int get_offset_x();
+        int get_offset_y();
+        int get_pos_x();
+        int get_pos_y();
+
+};
+
+#endif
\ No newline at end of file