A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
main.cpp@28:98848e6a77a2, 2019-05-02 (annotated)
- Committer:
- el17sm
- Date:
- Thu May 02 21:30:49 2019 +0000
- Revision:
- 28:98848e6a77a2
- Parent:
- 27:a1b41626f57c
- Child:
- 29:6b8411bb040a
Entrance and Exit done
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17sm | 0:8e92b66a0755 | 1 | /* |
el17sm | 0:8e92b66a0755 | 2 | ELEC2645 Embedded Systems Project |
el17sm | 0:8e92b66a0755 | 3 | School of Electronic & Electrical Engineering |
el17sm | 0:8e92b66a0755 | 4 | University of Leeds |
el17sm | 0:8e92b66a0755 | 5 | Name: Steven Mahasin |
el17sm | 0:8e92b66a0755 | 6 | Username: el17sm |
el17sm | 0:8e92b66a0755 | 7 | Student ID Number: 201192939 |
el17sm | 0:8e92b66a0755 | 8 | Date: 11/04/2019 |
el17sm | 1:1fa7ecca8dfb | 9 | */ |
el17sm | 1:1fa7ecca8dfb | 10 | |
el17sm | 27:a1b41626f57c | 11 | // Pre-Processor |
el17sm | 7:4aaa37a711a1 | 12 | #include "mbed.h" |
el17sm | 7:4aaa37a711a1 | 13 | #include "Gamepad.h" |
el17sm | 7:4aaa37a711a1 | 14 | #include "N5110.h" |
el17sm | 7:4aaa37a711a1 | 15 | #include "math.h" |
el17sm | 7:4aaa37a711a1 | 16 | #include "sprites.h" |
el17sm | 7:4aaa37a711a1 | 17 | #include "Entity.h" |
el17sm | 7:4aaa37a711a1 | 18 | #include "Player.h" |
el17sm | 10:1a3499f6b583 | 19 | #include "Headless.h" |
el17sm | 17:99e533f7f2fb | 20 | #include "Snake.h" |
el17sm | 27:a1b41626f57c | 21 | #include "RoomEngine.h" |
el17sm | 7:4aaa37a711a1 | 22 | |
el17sm | 28:98848e6a77a2 | 23 | #define INSIDE 4 |
el17sm | 28:98848e6a77a2 | 24 | #define MAX_ROOMS_MAP_X 10 |
el17sm | 28:98848e6a77a2 | 25 | #define MAX_ROOMS_MAP_Y 10 |
el17sm | 28:98848e6a77a2 | 26 | |
el17sm | 27:a1b41626f57c | 27 | // Objects |
el17sm | 7:4aaa37a711a1 | 28 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
el17sm | 7:4aaa37a711a1 | 29 | Gamepad gamepad; |
el17sm | 7:4aaa37a711a1 | 30 | |
el17sm | 27:a1b41626f57c | 31 | // Prototypes |
el17sm | 27:a1b41626f57c | 32 | void render(); |
el17sm | 10:1a3499f6b583 | 33 | |
el17sm | 27:a1b41626f57c | 34 | // Functions |
el17sm | 1:1fa7ecca8dfb | 35 | int main() |
el17sm | 1:1fa7ecca8dfb | 36 | { |
el17sm | 26:abbc19edc5c1 | 37 | // initialize |
el17sm | 1:1fa7ecca8dfb | 38 | lcd.init(); |
el17sm | 28:98848e6a77a2 | 39 | lcd.setContrast(0.5); |
el17sm | 3:359a49bace1b | 40 | gamepad.init(); |
el17sm | 28:98848e6a77a2 | 41 | Player player(39, 27); |
el17sm | 28:98848e6a77a2 | 42 | |
el17sm | 27:a1b41626f57c | 43 | while(1) { // gameloop |
el17sm | 27:a1b41626f57c | 44 | RoomEngine room_engine; |
el17sm | 28:98848e6a77a2 | 45 | Room room(2); |
el17sm | 28:98848e6a77a2 | 46 | // Rooms Generation |
el17sm | 28:98848e6a77a2 | 47 | while(player.get_hp() > 0) { // Room Loop |
el17sm | 28:98848e6a77a2 | 48 | while(1) { |
el17sm | 28:98848e6a77a2 | 49 | room.load(); |
el17sm | 28:98848e6a77a2 | 50 | room_engine.init(player, room); |
el17sm | 28:98848e6a77a2 | 51 | |
el17sm | 28:98848e6a77a2 | 52 | room_engine.entrance_scene(lcd, gamepad); |
el17sm | 28:98848e6a77a2 | 53 | while(room_engine.check_player_room_position() == INSIDE) { // Room actions |
el17sm | 28:98848e6a77a2 | 54 | room_engine.read_input(gamepad); |
el17sm | 28:98848e6a77a2 | 55 | room_engine.update(); |
el17sm | 28:98848e6a77a2 | 56 | room_engine.render(lcd, gamepad); |
el17sm | 28:98848e6a77a2 | 57 | } |
el17sm | 28:98848e6a77a2 | 58 | room_engine.exit_scene(lcd, gamepad); |
el17sm | 28:98848e6a77a2 | 59 | room.unload(); |
el17sm | 14:3361879490b2 | 60 | } |
el17sm | 10:1a3499f6b583 | 61 | } |
el17sm | 27:a1b41626f57c | 62 | lcd.clear(); |
el17sm | 28:98848e6a77a2 | 63 | lcd.setContrast(0.5); |
el17sm | 27:a1b41626f57c | 64 | lcd.printString("Game Over", 0, 0); |
el17sm | 27:a1b41626f57c | 65 | lcd.printString("Retry?", 0, 1); |
el17sm | 27:a1b41626f57c | 66 | lcd.refresh(); |
el17sm | 27:a1b41626f57c | 67 | room_engine.~RoomEngine(); |
el17sm | 27:a1b41626f57c | 68 | wait(0.05); |
el17sm | 27:a1b41626f57c | 69 | while(!gamepad.check_event(Gamepad::A_PRESSED)) { |
el17sm | 27:a1b41626f57c | 70 | } |
el17sm | 27:a1b41626f57c | 71 | wait(0.05); |
el17sm | 27:a1b41626f57c | 72 | while(gamepad.check_event(Gamepad::A_PRESSED)) { |
el17sm | 16:ddb203a74dfc | 73 | } |
el17sm | 22:7abf4581bc9b | 74 | } |
el17sm | 10:1a3499f6b583 | 75 | } |