A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
RoomEngine/RoomEngine.h@57:1c12361b6e3d, 2019-05-09 (annotated)
- Committer:
- el17sm
- Date:
- Thu May 09 09:50:19 2019 +0000
- Revision:
- 57:1c12361b6e3d
- Parent:
- 50:2c5cb92a5361
- Child:
- 58:c8d90bb7404a
All protected member has a _ before them
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17sm | 26:abbc19edc5c1 | 1 | #ifndef ROOMENGINE_H |
el17sm | 26:abbc19edc5c1 | 2 | #define ROOMENGINE_H |
el17sm | 28:98848e6a77a2 | 3 | #include "N5110.h" |
el17sm | 29:6b8411bb040a | 4 | #include "Gamepad.h" |
el17sm | 29:6b8411bb040a | 5 | |
el17sm | 26:abbc19edc5c1 | 6 | #include "Player.h" |
el17sm | 29:6b8411bb040a | 7 | #include "Health.h" |
el17sm | 26:abbc19edc5c1 | 8 | #include "Room.h" |
el17sm | 29:6b8411bb040a | 9 | |
el17sm | 26:abbc19edc5c1 | 10 | #include "sprites.h" |
el17sm | 46:f09711580d4a | 11 | #define MAX_ROOMS_MAP_X 11 |
el17sm | 46:f09711580d4a | 12 | #define MAX_ROOMS_MAP_Y 11 |
el17sm | 29:6b8411bb040a | 13 | |
el17sm | 26:abbc19edc5c1 | 14 | |
el17sm | 27:a1b41626f57c | 15 | class RoomEngine |
el17sm | 26:abbc19edc5c1 | 16 | { |
el17sm | 26:abbc19edc5c1 | 17 | public: |
el17sm | 32:fe6359ef9916 | 18 | // Constructor |
el17sm | 41:0697508a28ba | 19 | RoomEngine(float global_contrast); |
el17sm | 32:fe6359ef9916 | 20 | // Destructor |
el17sm | 27:a1b41626f57c | 21 | ~RoomEngine(); |
el17sm | 32:fe6359ef9916 | 22 | |
el17sm | 32:fe6359ef9916 | 23 | // Functions |
el17sm | 31:ab24d028ddfd | 24 | void load(Player *current_player, Room *current_room); |
el17sm | 28:98848e6a77a2 | 25 | void entrance_scene(N5110 &lcd, Gamepad &gamepad); |
el17sm | 29:6b8411bb040a | 26 | void update_current_room(); |
el17sm | 29:6b8411bb040a | 27 | |
el17sm | 50:2c5cb92a5361 | 28 | int check_player_room_position(); |
el17sm | 50:2c5cb92a5361 | 29 | |
el17sm | 26:abbc19edc5c1 | 30 | void read_input(Gamepad &gamepad); |
el17sm | 47:6e31b195ce3c | 31 | void update(int &number_of_enemies_killed); |
el17sm | 27:a1b41626f57c | 32 | void render(N5110 &lcd, Gamepad &gamepad); |
el17sm | 32:fe6359ef9916 | 33 | |
el17sm | 50:2c5cb92a5361 | 34 | void exit_scene(N5110 &lcd, Gamepad &gamepad); |
el17sm | 26:abbc19edc5c1 | 35 | |
el17sm | 29:6b8411bb040a | 36 | // Accessor |
el17sm | 29:6b8411bb040a | 37 | int get_room_x(); |
el17sm | 29:6b8411bb040a | 38 | int get_room_y(); |
el17sm | 29:6b8411bb040a | 39 | |
el17sm | 26:abbc19edc5c1 | 40 | private: |
el17sm | 57:1c12361b6e3d | 41 | // Member variables |
el17sm | 26:abbc19edc5c1 | 42 | bool _L; |
el17sm | 26:abbc19edc5c1 | 43 | bool _R; |
el17sm | 26:abbc19edc5c1 | 44 | bool _A; |
el17sm | 26:abbc19edc5c1 | 45 | bool _B; |
el17sm | 26:abbc19edc5c1 | 46 | bool _X; |
el17sm | 26:abbc19edc5c1 | 47 | bool _Y; |
el17sm | 26:abbc19edc5c1 | 48 | Vector2D mapped_coord; |
el17sm | 26:abbc19edc5c1 | 49 | |
el17sm | 29:6b8411bb040a | 50 | int _room_x; |
el17sm | 29:6b8411bb040a | 51 | int _room_y; |
el17sm | 29:6b8411bb040a | 52 | |
el17sm | 30:ec915d24d3e9 | 53 | float _global_contrast; |
el17sm | 30:ec915d24d3e9 | 54 | |
el17sm | 27:a1b41626f57c | 55 | Room *room; |
el17sm | 27:a1b41626f57c | 56 | Player *player; |
el17sm | 26:abbc19edc5c1 | 57 | |
el17sm | 28:98848e6a77a2 | 58 | // Mutator |
el17sm | 28:98848e6a77a2 | 59 | void set_input(bool L, bool R, bool A, bool B, bool X, bool Y, float mapped_x, float mapped_y); |
el17sm | 28:98848e6a77a2 | 60 | void set_mapped_coord(float x, float y); |
el17sm | 28:98848e6a77a2 | 61 | |
el17sm | 49:3f83ed62d123 | 62 | // Methods |
el17sm | 28:98848e6a77a2 | 63 | bool entity_collision(Entity &a, Entity &b); |
el17sm | 28:98848e6a77a2 | 64 | float entity_move_check_x(Entity *a, Entity *array[], int no_of_enemies, int current_entity, bool valid_enemies[]); |
el17sm | 28:98848e6a77a2 | 65 | float entity_move_check_y(Entity *a, Entity *array[], int no_of_enemies, int current_entity, bool valid_enemies[]); |
el17sm | 28:98848e6a77a2 | 66 | |
el17sm | 26:abbc19edc5c1 | 67 | void check_damage(); |
el17sm | 26:abbc19edc5c1 | 68 | void check_damage_player(); |
el17sm | 26:abbc19edc5c1 | 69 | void check_damage_enemies(); |
el17sm | 47:6e31b195ce3c | 70 | void check_enemies_death(int &number_of_enemies_killed); |
el17sm | 41:0697508a28ba | 71 | void check_walls_collision(); |
el17sm | 41:0697508a28ba | 72 | |
el17sm | 26:abbc19edc5c1 | 73 | void move(); |
el17sm | 26:abbc19edc5c1 | 74 | void move_player(); |
el17sm | 26:abbc19edc5c1 | 75 | void move_enemies(); |
el17sm | 28:98848e6a77a2 | 76 | void update_player_position(int side); |
el17sm | 28:98848e6a77a2 | 77 | |
el17sm | 27:a1b41626f57c | 78 | void pause_detection(N5110 &lcd, Gamepad &gamepad); |
el17sm | 49:3f83ed62d123 | 79 | void draw_pause_screen(N5110 &lcd, char * paused_screen, int &pause_timer); |
el17sm | 26:abbc19edc5c1 | 80 | |
el17sm | 27:a1b41626f57c | 81 | void draw(N5110 &lcd); |
el17sm | 26:abbc19edc5c1 | 82 | void draw_health(N5110 &lcd); |
el17sm | 26:abbc19edc5c1 | 83 | |
el17sm | 26:abbc19edc5c1 | 84 | }; |
el17sm | 26:abbc19edc5c1 | 85 | #endif |