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:
- RehamFaqehi
- Date:
- 2018-05-03
- Revision:
- 10:3af708f38a42
- Parent:
- 9:e70179ff61c5
- Child:
- 11:cb48d596aa3e
File content as of revision 10:3af708f38a42:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds Name: Reham Faqehi Username: Fy15raf Student ID Number: 200982112 Date: 03/05/2018 */ ///////// pre-processor directives //////// #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "GameEngine.h" /////////////// objects /////////////// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad g_pad; GameEngine game; ///////////// prototypes /////////////// void init(); void render(); void welcome(); void gameOver(); ///////////// functions //////////////// int main() { int fps = 8; // frames per second int sleep=0; init(); // initialise welcome(); // display welcome screen till the user press start to start the game render(); // drawing the initial frame wait(1.0f/fps); // wait for one frame period // game loop while (game.get_gameOver1()!=1) { g_pad.led(1, 0); g_pad.led(4, 0); g_pad.led(3, 2); g_pad.led(6, 2); game.read_input(g_pad); game.update(g_pad,lcd); render(); wait(1.0f/fps); while(g_pad.check_event(Gamepad::BACK_PRESSED) == true || sleep ==1) { sleep=1; ///red leds on , greens are off g_pad.led(1, 2); g_pad.led(4, 2); g_pad.led(3, 0); g_pad.led(6, 0); // sleep(); if(g_pad.check_event(Gamepad::START_PRESSED) == true){ sleep=0; break; } } } lcd.clear(); gameOver(); } // initialies all classes and libraries void init() { //initialise LCD and Gamepad first lcd.init(); lcd.setContrast(0.5); g_pad.init(); // initialise the game game.init(); } //function to draw the frames on the LCD void render() { // first clear screen, re-draw and then refresh the LCD lcd.clear(); game.draw(lcd); lcd.refresh(); } // simple welcoming screen before starting the game void welcome() { lcd.printString(" Rocket! ",0,1); lcd.printString(" Press Start ",0,4); lcd.refresh(); //flashing LEDs until start button is pressed while ( g_pad.check_event(Gamepad::START_PRESSED) == false) { g_pad.leds_on(); wait(0.1); g_pad.leds_off(); wait(0.1); } } void gameOver() { lcd.printString(" Game Over!! ",0,1); lcd.printString(" Try again ",0,3); lcd.printString(" 'reset' ",0,5); lcd.refresh(); }