A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
Entity/Entity.h@13:d04a6caba40d, 2019-04-24 (annotated)
- Committer:
- el17sm
- Date:
- Wed Apr 24 02:33:33 2019 +0000
- Revision:
- 13:d04a6caba40d
- Parent:
- 12:a1c1991835ca
- Child:
- 14:3361879490b2
Added bullets (error)
Who changed what in which revision?
User | Revision | Line number | New 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 | 10:1a3499f6b583 | 7 | { |
el17sm | 10:1a3499f6b583 | 8 | protected: |
el17sm | 10:1a3499f6b583 | 9 | bool moving; |
el17sm | 10:1a3499f6b583 | 10 | struct Hitbox { |
el17sm | 10:1a3499f6b583 | 11 | int width; |
el17sm | 10:1a3499f6b583 | 12 | int height; |
el17sm | 10:1a3499f6b583 | 13 | }; |
el17sm | 10:1a3499f6b583 | 14 | Hitbox hitbox; |
el17sm | 10:1a3499f6b583 | 15 | struct SpriteSize { |
el17sm | 10:1a3499f6b583 | 16 | int width; |
el17sm | 10:1a3499f6b583 | 17 | int height; |
el17sm | 10:1a3499f6b583 | 18 | // Top-left corner of sprite is offset_x |
el17sm | 10:1a3499f6b583 | 19 | // to the right of top-left corner of hitbox |
el17sm | 10:1a3499f6b583 | 20 | int offset_x; |
el17sm | 10:1a3499f6b583 | 21 | // Top-left corner of sprite is offset_y |
el17sm | 10:1a3499f6b583 | 22 | // above of top-left corner of hitbox |
el17sm | 10:1a3499f6b583 | 23 | int offset_y; |
el17sm | 10:1a3499f6b583 | 24 | }; |
el17sm | 10:1a3499f6b583 | 25 | SpriteSize sprite_size; |
el17sm | 10:1a3499f6b583 | 26 | struct Position { |
el17sm | 10:1a3499f6b583 | 27 | float x; |
el17sm | 10:1a3499f6b583 | 28 | float y; |
el17sm | 10:1a3499f6b583 | 29 | }; |
el17sm | 10:1a3499f6b583 | 30 | Position position; |
el17sm | 11:63e54f6e7939 | 31 | Position prev_pos; |
el17sm | 12:a1c1991835ca | 32 | struct FrameCount { |
el17sm | 12:a1c1991835ca | 33 | int count; |
el17sm | 12:a1c1991835ca | 34 | int number; |
el17sm | 12:a1c1991835ca | 35 | int max; |
el17sm | 12:a1c1991835ca | 36 | }; |
el17sm | 12:a1c1991835ca | 37 | FrameCount frame; |
el17sm | 10:1a3499f6b583 | 38 | int hp; |
el17sm | 10:1a3499f6b583 | 39 | int face; |
el17sm | 10:1a3499f6b583 | 40 | |
el17sm | 10:1a3499f6b583 | 41 | public: |
el17sm | 13:d04a6caba40d | 42 | // Function |
el17sm | 12:a1c1991835ca | 43 | virtual void move(float, float) = 0; // movement control and miscellaneous updates |
el17sm | 12:a1c1991835ca | 44 | virtual int * get_frame() = 0; |
el17sm | 13:d04a6caba40d | 45 | bool matrix_collision_test(float, float, int); |
el17sm | 13:d04a6caba40d | 46 | void undo_move_x(bool); |
el17sm | 13:d04a6caba40d | 47 | void undo_move_y(bool); |
el17sm | 13:d04a6caba40d | 48 | void update_prev_pos(); |
el17sm | 13:d04a6caba40d | 49 | void take_damage(int); |
el17sm | 10:1a3499f6b583 | 50 | |
el17sm | 13:d04a6caba40d | 51 | // Mutator |
el17sm | 11:63e54f6e7939 | 52 | |
el17sm | 10:1a3499f6b583 | 53 | // Accessors |
el17sm | 10:1a3499f6b583 | 54 | bool get_moving(); |
el17sm | 10:1a3499f6b583 | 55 | int get_hitbox_width(); |
el17sm | 10:1a3499f6b583 | 56 | int get_hitbox_height(); |
el17sm | 10:1a3499f6b583 | 57 | int get_face(); |
el17sm | 10:1a3499f6b583 | 58 | int get_sprite_width(); |
el17sm | 10:1a3499f6b583 | 59 | int get_sprite_height(); |
el17sm | 10:1a3499f6b583 | 60 | int get_offset_x(); |
el17sm | 10:1a3499f6b583 | 61 | int get_offset_y(); |
el17sm | 10:1a3499f6b583 | 62 | int get_pos_x(); |
el17sm | 10:1a3499f6b583 | 63 | int get_pos_y(); |
el17sm | 11:63e54f6e7939 | 64 | int get_prev_pos_x(); |
el17sm | 11:63e54f6e7939 | 65 | int get_prev_pos_y(); |
el17sm | 10:1a3499f6b583 | 66 | |
el17sm | 10:1a3499f6b583 | 67 | }; |
el17sm | 10:1a3499f6b583 | 68 | |
el17sm | 10:1a3499f6b583 | 69 | #endif |