A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.
Dependencies: mbed MotionSensor
main.cpp@7:4aaa37a711a1, 2019-04-20 (annotated)
- Committer:
- el17sm
- Date:
- Sat Apr 20 22:17:24 2019 +0000
- Revision:
- 7:4aaa37a711a1
- Parent:
- 6:104c2506237e
- Child:
- 10:1a3499f6b583
Implementation of Entity.h and Person.h;
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 | 7:4aaa37a711a1 | 11 | #include "mbed.h" |
el17sm | 7:4aaa37a711a1 | 12 | #include "Gamepad.h" |
el17sm | 7:4aaa37a711a1 | 13 | #include "N5110.h" |
el17sm | 7:4aaa37a711a1 | 14 | #include "math.h" |
el17sm | 7:4aaa37a711a1 | 15 | #include "sprites.h" |
el17sm | 7:4aaa37a711a1 | 16 | #include "Entity.h" |
el17sm | 7:4aaa37a711a1 | 17 | #include "Player.h" |
el17sm | 7:4aaa37a711a1 | 18 | |
el17sm | 7:4aaa37a711a1 | 19 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
el17sm | 7:4aaa37a711a1 | 20 | Gamepad gamepad; |
el17sm | 7:4aaa37a711a1 | 21 | |
el17sm | 7:4aaa37a711a1 | 22 | int counter = 0; |
el17sm | 1:1fa7ecca8dfb | 23 | |
el17sm | 1:1fa7ecca8dfb | 24 | int main() |
el17sm | 1:1fa7ecca8dfb | 25 | { |
el17sm | 1:1fa7ecca8dfb | 26 | lcd.init(); |
el17sm | 2:dbfff27a8a94 | 27 | lcd.setContrast(0.45); |
el17sm | 3:359a49bace1b | 28 | gamepad.init(); |
el17sm | 7:4aaa37a711a1 | 29 | Player player(39, 27); |
el17sm | 3:359a49bace1b | 30 | |
el17sm | 2:dbfff27a8a94 | 31 | while(1){ |
el17sm | 7:4aaa37a711a1 | 32 | // Player Movement |
el17sm | 7:4aaa37a711a1 | 33 | // Enemy Movement |
el17sm | 2:dbfff27a8a94 | 34 | |
el17sm | 7:4aaa37a711a1 | 35 | // MiniMap Generation |
el17sm | 7:4aaa37a711a1 | 36 | // MiniMap Screen Detection |
el17sm | 7:4aaa37a711a1 | 37 | |
el17sm | 7:4aaa37a711a1 | 38 | // Pause Detection |
el17sm | 7:4aaa37a711a1 | 39 | |
el17sm | 7:4aaa37a711a1 | 40 | // screen update |
el17sm | 7:4aaa37a711a1 | 41 | |
el17sm | 7:4aaa37a711a1 | 42 | Vector2D mapped_coord = gamepad.get_mapped_coord(); |
el17sm | 7:4aaa37a711a1 | 43 | player.move(mapped_coord.x, mapped_coord.y); |
el17sm | 3:359a49bace1b | 44 | |
el17sm | 3:359a49bace1b | 45 | lcd.clear(); |
el17sm | 7:4aaa37a711a1 | 46 | lcd.drawSprite(0,0,screen_height,screen_width,(int *)level_map[1]); |
el17sm | 7:4aaa37a711a1 | 47 | lcd.drawSpriteTransparent(player.get_pos_x()-player.get_offset_x(), |
el17sm | 7:4aaa37a711a1 | 48 | player.get_pos_y()-player.get_offset_y(), |
el17sm | 7:4aaa37a711a1 | 49 | player.get_sprite_height(), |
el17sm | 7:4aaa37a711a1 | 50 | player.get_sprite_width(), |
el17sm | 7:4aaa37a711a1 | 51 | (int *)sprite_player[player.get_face()][(int)(player.get_moving()*(counter/5)%4)]); |
el17sm | 3:359a49bace1b | 52 | lcd.refresh(); |
el17sm | 6:104c2506237e | 53 | wait_ms(1000/20); |
el17sm | 3:359a49bace1b | 54 | counter++; |
el17sm | 2:dbfff27a8a94 | 55 | |
el17sm | 2:dbfff27a8a94 | 56 | } |
el17sm | 7:4aaa37a711a1 | 57 | |
el17sm | 7:4aaa37a711a1 | 58 | } |