ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

Committer:
el17m2h
Date:
Wed Apr 10 17:34:02 2019 +0000
Revision:
2:360a6c301a4e
Parent:
1:0001cb3eb053
Child:
3:116913e97fd7
I created an engine .cpp and .h file to add 10 floors to the screen once the button start is pressed and I used the rand syntax to place them in random positions within the screen

Who changed what in which revision?

UserRevisionLine numberNew 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 1:0001cb3eb053 6 #define FLOORS_WIDTH 2
el17m2h 1:0001cb3eb053 7 #define FLOORS_HEIGHT 10
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 int fps = 8; // frames per second
el17m2h 1:0001cb3eb053 22 init(); // initialise and then display welcome screen...
el17m2h 1:0001cb3eb053 23 while(1){
el17m2h 1:0001cb3eb053 24 welcome();
el17m2h 1:0001cb3eb053 25 if ( pad.check_event(Gamepad::START_PRESSED) == true) {
el17m2h 1:0001cb3eb053 26 break; }
el17m2h 1:0001cb3eb053 27 }
el17m2h 1:0001cb3eb053 28 draw();
el17m2h 1:0001cb3eb053 29 }
el17m2h 1:0001cb3eb053 30
el17m2h 1:0001cb3eb053 31 // initialies all classes and libraries
el17m2h 1:0001cb3eb053 32 void init(){
el17m2h 1:0001cb3eb053 33 // need to initialise LCD and Gamepad
el17m2h 1:0001cb3eb053 34 lcd.init();
el17m2h 1:0001cb3eb053 35 pad.init();
el17m2h 2:360a6c301a4e 36 eng.init(FLOORS_HEIGHT, FLOORS_WIDTH);
el17m2h 1:0001cb3eb053 37 }
el17m2h 1:0001cb3eb053 38
el17m2h 1:0001cb3eb053 39 // Starting menu screen display
el17m2h 1:0001cb3eb053 40 void welcome() {
el17m2h 1:0001cb3eb053 41 lcd.printString(" Doodle Jump! ",0,1);
el17m2h 1:0001cb3eb053 42 lcd.printString(" Press Start ",0,4);
el17m2h 1:0001cb3eb053 43 lcd.refresh();
el17m2h 1:0001cb3eb053 44 }
el17m2h 1:0001cb3eb053 45
el17m2h 1:0001cb3eb053 46 void draw(){
el17m2h 1:0001cb3eb053 47 lcd.clear();
el17m2h 2:360a6c301a4e 48 eng.draw(lcd);
el17m2h 1:0001cb3eb053 49 lcd.refresh();
el17m2h 1:0001cb3eb053 50 }