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
- Committer:
- el17m2h
- Date:
- 2019-05-08
- Revision:
- 26:d16a5b1e0ace
- Parent:
- 24:67dc71a8f009
- Child:
- 27:af14fcd5a520
File content as of revision 26:d16a5b1e0ace:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds Name: Melissa Hartmann Username: el17m2h Student ID Number: 201176603 Date: 09/05/2019 */ #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "Engine.h" //structs struct UserInput { Direction d; float mag; }; // 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; Doodler dood; Enemy eny; // prototypes void init(); void update_game(UserInput input); void render(); void welcome(); void game_over(); // functions int main(){ while(1){ init(); welcome(); int fps = 8; render(); // draws wait(1.0f/fps); while(1){ eng.read_input(pad); eng.update(pad); render(); wait(0.8f/fps); if (pad.check_event(Gamepad::BACK_PRESSED) == true){ break; } } render(); wait(0.1); } } // initialies all classes and libraries void init(){ // need to initialise LCD and Gamepad lcd.init(); lcd.setBrightness(1); lcd.setContrast(0.5), pad.init(); eng.init(); } void render(){ lcd.clear(); eng.draw(lcd); lcd.refresh(); } // Starting menu screen display void welcome() { lcd.printString(" Doodle Jump! ",0,1); lcd.printString(" Press Start ",0,4); lcd.refresh(); while ( pad.check_event(Gamepad::START_PRESSED) == false) { pad.leds_on(); wait(0.1); pad.leds_off(); wait(0.1); } } void game_over() { lcd.clear(); lcd.printString("Game Over!",3,1); lcd.printString("Press back",3,3); lcd.printString("SCORE = ",3,5); lcd.refresh(); while ( pad.check_event(Gamepad::BACK_PRESSED) == false) { pad.leds_on(); wait(0.1); pad.leds_off(); wait(0.1); } }