Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@3:116913e97fd7, 2019-04-10 (annotated)
- Committer:
- el17m2h
- Date:
- Wed Apr 10 19:07:41 2019 +0000
- Revision:
- 3:116913e97fd7
- Parent:
- 2:360a6c301a4e
- Child:
- 4:8ec314f806ae
I added 10 floors and made their position be random on the screen. I divided these in ranges in order to avoid the collision of the floors and also changed the width to have a random length between 10 and 15.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17m2h | 1:0001cb3eb053 | 1 | #include "mbed.h" |
el17m2h | 1:0001cb3eb053 | 2 | #include "Gamepad.h" |
el17m2h | 1:0001cb3eb053 | 3 | #include "N5110.h" |
el17m2h | 2:360a6c301a4e | 4 | #include "Engine.h" |
el17m2h | 1:0001cb3eb053 | 5 | |
el17m2h | 3:116913e97fd7 | 6 | #define FLOORS_WIDTH rand() % 15 + 10 // floors width between 10 to 15 |
el17m2h | 3:116913e97fd7 | 7 | #define FLOORS_HEIGHT 2 |
el17m2h | 1:0001cb3eb053 | 8 | |
el17m2h | 1:0001cb3eb053 | 9 | // objects |
el17m2h | 1:0001cb3eb053 | 10 | N5110 lcd(PTC5,PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // START, LCD SCE, LCD RST, LCD DC, LCD MOSI, LCD CLK, LCD Backlight |
el17m2h | 1:0001cb3eb053 | 11 | Gamepad pad; |
el17m2h | 2:360a6c301a4e | 12 | Engine eng; |
el17m2h | 1:0001cb3eb053 | 13 | |
el17m2h | 1:0001cb3eb053 | 14 | // prototypes |
el17m2h | 1:0001cb3eb053 | 15 | void init(); |
el17m2h | 1:0001cb3eb053 | 16 | void draw(); |
el17m2h | 1:0001cb3eb053 | 17 | void welcome(); |
el17m2h | 1:0001cb3eb053 | 18 | |
el17m2h | 1:0001cb3eb053 | 19 | // functions |
el17m2h | 1:0001cb3eb053 | 20 | int main(){ |
el17m2h | 1:0001cb3eb053 | 21 | init(); // initialise and then display welcome screen... |
el17m2h | 1:0001cb3eb053 | 22 | while(1){ |
el17m2h | 1:0001cb3eb053 | 23 | welcome(); |
el17m2h | 1:0001cb3eb053 | 24 | if ( pad.check_event(Gamepad::START_PRESSED) == true) { |
el17m2h | 1:0001cb3eb053 | 25 | break; } |
el17m2h | 1:0001cb3eb053 | 26 | } |
el17m2h | 1:0001cb3eb053 | 27 | draw(); |
el17m2h | 1:0001cb3eb053 | 28 | } |
el17m2h | 1:0001cb3eb053 | 29 | |
el17m2h | 1:0001cb3eb053 | 30 | // initialies all classes and libraries |
el17m2h | 1:0001cb3eb053 | 31 | void init(){ |
el17m2h | 1:0001cb3eb053 | 32 | // need to initialise LCD and Gamepad |
el17m2h | 1:0001cb3eb053 | 33 | lcd.init(); |
el17m2h | 1:0001cb3eb053 | 34 | pad.init(); |
el17m2h | 3:116913e97fd7 | 35 | eng.init(FLOORS_WIDTH, FLOORS_HEIGHT); |
el17m2h | 1:0001cb3eb053 | 36 | } |
el17m2h | 1:0001cb3eb053 | 37 | |
el17m2h | 1:0001cb3eb053 | 38 | // Starting menu screen display |
el17m2h | 1:0001cb3eb053 | 39 | void welcome() { |
el17m2h | 1:0001cb3eb053 | 40 | lcd.printString(" Doodle Jump! ",0,1); |
el17m2h | 1:0001cb3eb053 | 41 | lcd.printString(" Press Start ",0,4); |
el17m2h | 1:0001cb3eb053 | 42 | lcd.refresh(); |
el17m2h | 1:0001cb3eb053 | 43 | } |
el17m2h | 1:0001cb3eb053 | 44 | |
el17m2h | 1:0001cb3eb053 | 45 | void draw(){ |
el17m2h | 1:0001cb3eb053 | 46 | lcd.clear(); |
el17m2h | 2:360a6c301a4e | 47 | eng.draw(lcd); |
el17m2h | 1:0001cb3eb053 | 48 | lcd.refresh(); |
el17m2h | 1:0001cb3eb053 | 49 | } |