A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
main.cpp@27:a1b41626f57c, 2019-04-29 (annotated)
- Committer:
- el17sm
- Date:
- Mon Apr 29 10:39:09 2019 +0000
- Revision:
- 27:a1b41626f57c
- Parent:
- 26:abbc19edc5c1
- Child:
- 28:98848e6a77a2
Functional Room; Great Success;
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 | 27:a1b41626f57c | 23 | // Objects |
el17sm | 7:4aaa37a711a1 | 24 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
el17sm | 7:4aaa37a711a1 | 25 | Gamepad gamepad; |
el17sm | 7:4aaa37a711a1 | 26 | |
el17sm | 27:a1b41626f57c | 27 | // Prototypes |
el17sm | 27:a1b41626f57c | 28 | void render(); |
el17sm | 10:1a3499f6b583 | 29 | |
el17sm | 27:a1b41626f57c | 30 | // Functions |
el17sm | 1:1fa7ecca8dfb | 31 | int main() |
el17sm | 1:1fa7ecca8dfb | 32 | { |
el17sm | 26:abbc19edc5c1 | 33 | // initialize |
el17sm | 1:1fa7ecca8dfb | 34 | lcd.init(); |
el17sm | 2:dbfff27a8a94 | 35 | lcd.setContrast(0.45); |
el17sm | 3:359a49bace1b | 36 | gamepad.init(); |
el17sm | 22:7abf4581bc9b | 37 | |
el17sm | 27:a1b41626f57c | 38 | while(1) { // gameloop |
el17sm | 27:a1b41626f57c | 39 | RoomEngine room_engine; |
el17sm | 27:a1b41626f57c | 40 | while(1) { // floorloop |
el17sm | 27:a1b41626f57c | 41 | Room room; |
el17sm | 27:a1b41626f57c | 42 | room.init(); |
el17sm | 27:a1b41626f57c | 43 | room_engine.load_room(room); |
el17sm | 27:a1b41626f57c | 44 | while(!room_engine.check_player_death()) { // roomloop |
el17sm | 27:a1b41626f57c | 45 | room_engine.read_input(gamepad); |
el17sm | 27:a1b41626f57c | 46 | room_engine.update(); |
el17sm | 27:a1b41626f57c | 47 | room_engine.render(lcd, gamepad); |
el17sm | 14:3361879490b2 | 48 | } |
el17sm | 27:a1b41626f57c | 49 | break; |
el17sm | 10:1a3499f6b583 | 50 | } |
el17sm | 27:a1b41626f57c | 51 | lcd.clear(); |
el17sm | 27:a1b41626f57c | 52 | lcd.printString("Game Over", 0, 0); |
el17sm | 27:a1b41626f57c | 53 | lcd.printString("Retry?", 0, 1); |
el17sm | 27:a1b41626f57c | 54 | lcd.refresh(); |
el17sm | 27:a1b41626f57c | 55 | room_engine.~RoomEngine(); |
el17sm | 27:a1b41626f57c | 56 | wait(0.05); |
el17sm | 27:a1b41626f57c | 57 | while(!gamepad.check_event(Gamepad::A_PRESSED)) { |
el17sm | 27:a1b41626f57c | 58 | } |
el17sm | 27:a1b41626f57c | 59 | wait(0.05); |
el17sm | 27:a1b41626f57c | 60 | while(gamepad.check_event(Gamepad::A_PRESSED)) { |
el17sm | 16:ddb203a74dfc | 61 | } |
el17sm | 22:7abf4581bc9b | 62 | } |
el17sm | 10:1a3499f6b583 | 63 | } |