ELEC2645 (2018/19) / Mbed 2 deprecated el17m2h_public

Dependencies:   mbed

main.cpp

Committer:
el17m2h
Date:
2019-04-11
Revision:
4:8ec314f806ae
Parent:
3:116913e97fd7
Child:
5:8814d6de77d0

File content as of revision 4:8ec314f806ae:

#include "mbed.h" 
#include "Gamepad.h" 
#include "N5110.h" 
#include "Engine.h"  

#define FLOORS_WIDTH 12 
#define FLOORS_HEIGHT 2
#define DOODLER_RADIUS 3

// objects
N5110 lcd(PTC5,PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); // START, LCD SCE, LCD RST, LCD DC, LCD MOSI, LCD CLK, LCD Backlight
Gamepad pad;
Engine eng;

// prototypes 
void init();
void draw();
void welcome();

// functions
int main(){
    init();     // initialise and then display welcome screen...
    while(1){   
      welcome();
      if ( pad.check_event(Gamepad::START_PRESSED) == true) {      
           break; }
    }
    draw();  
}

// initialies all classes and libraries
void init(){
    // need to initialise LCD and Gamepad 
    lcd.init();
    pad.init();
    eng.init(FLOORS_WIDTH, FLOORS_HEIGHT, DOODLER_RADIUS);
}

// Starting menu screen display
void welcome() {   
    lcd.printString(" Doodle Jump! ",0,1);  
    lcd.printString("  Press Start ",0,4);
    lcd.refresh();
 }
 
void draw(){
    lcd.clear();
    eng.draw(lcd);
    lcd.refresh();
}