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

Dependencies:   mbed MotionSensor

Committer:
el17sm
Date:
Thu Apr 25 23:15:44 2019 +0000
Revision:
23:5a8f75e93508
Parent:
22:7abf4581bc9b
Child:
24:26369d92a06a
Added Health;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17sm 10:1a3499f6b583 1 #ifndef ENTITY_H
el17sm 10:1a3499f6b583 2 #define ENTITY_H
el17sm 10:1a3499f6b583 3 #include "sprites.h"
el17sm 10:1a3499f6b583 4 #include "math.h"
el17sm 10:1a3499f6b583 5
el17sm 10:1a3499f6b583 6 class Entity
el17sm 22:7abf4581bc9b 7 {
el17sm 22:7abf4581bc9b 8 protected:
el17sm 22:7abf4581bc9b 9 bool moving;
el17sm 22:7abf4581bc9b 10 struct Hitbox {
el17sm 22:7abf4581bc9b 11 int width;
el17sm 22:7abf4581bc9b 12 int height;
el17sm 22:7abf4581bc9b 13 };
el17sm 22:7abf4581bc9b 14 Hitbox hitbox;
el17sm 22:7abf4581bc9b 15 struct SpriteSize {
el17sm 22:7abf4581bc9b 16 int width;
el17sm 22:7abf4581bc9b 17 int height;
el17sm 22:7abf4581bc9b 18 // Top-left corner of sprite is offset_x
el17sm 22:7abf4581bc9b 19 // to the right of top-left corner of hitbox
el17sm 22:7abf4581bc9b 20 int offset_x;
el17sm 22:7abf4581bc9b 21 // Top-left corner of sprite is offset_y
el17sm 22:7abf4581bc9b 22 // above of top-left corner of hitbox
el17sm 22:7abf4581bc9b 23 int offset_y;
el17sm 22:7abf4581bc9b 24 };
el17sm 22:7abf4581bc9b 25 SpriteSize sprite_size;
el17sm 22:7abf4581bc9b 26 struct Position {
el17sm 22:7abf4581bc9b 27 float x;
el17sm 22:7abf4581bc9b 28 float y;
el17sm 22:7abf4581bc9b 29 };
el17sm 22:7abf4581bc9b 30 Position position;
el17sm 22:7abf4581bc9b 31 Position prev_pos;
el17sm 22:7abf4581bc9b 32 struct FrameCount {
el17sm 22:7abf4581bc9b 33 int count;
el17sm 22:7abf4581bc9b 34 int number;
el17sm 22:7abf4581bc9b 35 int max;
el17sm 22:7abf4581bc9b 36 };
el17sm 22:7abf4581bc9b 37 FrameCount frame;
el17sm 22:7abf4581bc9b 38 int hp;
el17sm 23:5a8f75e93508 39 int attack;
el17sm 22:7abf4581bc9b 40 int face;
el17sm 22:7abf4581bc9b 41 float velocity;
el17sm 22:7abf4581bc9b 42
el17sm 22:7abf4581bc9b 43 public:
el17sm 22:7abf4581bc9b 44 // Function
el17sm 22:7abf4581bc9b 45 virtual void move(float, float) = 0; // movement control and miscellaneous updates
el17sm 22:7abf4581bc9b 46 virtual int * get_frame() = 0;
el17sm 23:5a8f75e93508 47 virtual void take_damage(int) = 0;
el17sm 22:7abf4581bc9b 48 bool matrix_collision_test(float, float, int);
el17sm 22:7abf4581bc9b 49 void undo_move_x(bool);
el17sm 22:7abf4581bc9b 50 void undo_move_y(bool);
el17sm 22:7abf4581bc9b 51 void update_prev_pos();
el17sm 22:7abf4581bc9b 52 bool death_check();
el17sm 22:7abf4581bc9b 53
el17sm 22:7abf4581bc9b 54 // Mutator
el17sm 22:7abf4581bc9b 55
el17sm 22:7abf4581bc9b 56 // Accessors
el17sm 22:7abf4581bc9b 57 bool get_moving();
el17sm 22:7abf4581bc9b 58 int get_hitbox_width();
el17sm 22:7abf4581bc9b 59 int get_hitbox_height();
el17sm 22:7abf4581bc9b 60 int get_face();
el17sm 22:7abf4581bc9b 61 int get_sprite_width();
el17sm 22:7abf4581bc9b 62 int get_sprite_height();
el17sm 22:7abf4581bc9b 63 int get_offset_x();
el17sm 22:7abf4581bc9b 64 int get_offset_y();
el17sm 22:7abf4581bc9b 65 int get_pos_x();
el17sm 22:7abf4581bc9b 66 int get_pos_y();
el17sm 22:7abf4581bc9b 67 int get_prev_pos_x();
el17sm 22:7abf4581bc9b 68 int get_prev_pos_y();
el17sm 23:5a8f75e93508 69 int get_attack();
el17sm 23:5a8f75e93508 70 int get_hp();
el17sm 10:1a3499f6b583 71
el17sm 10:1a3499f6b583 72 };
el17sm 10:1a3499f6b583 73
el17sm 10:1a3499f6b583 74 #endif