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:
- davidwst421
- Date:
- 2019-05-08
- Revision:
- 4:fcd80b40f257
- Parent:
- 3:53f0365461c0
- Child:
- 6:a0f3dbbc8d33
File content as of revision 4:fcd80b40f257:
/* ELEC2645 Embedded Systems Project School of Electronic & Electrical Engineering University of Leeds Name: Siuting Wong Username: Siuting Wong Student ID Number: 201186503 Date: 06/05/2019 */ ///////// pre-processor directives //////// #include "mbed.h" #include "Gamepad.h" #include "N5110.h" #include "Engine.h" #define WALL_WIDTH 2 #define WALL_GAP 10 #define AVENGER_SIZE 2 #define STONE_SIZE 1 #define SPEED 2 /////////////// structs ///////////////// struct UserInput { Direction d; float mag; }; /////////////// objects /////////////// N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); Gamepad pad; Engine eng; ///////////// prototypes /////////////// void init(); void update_game(UserInput input); void render(); void welcome(); void endgame(); ///////////// functions //////////////// int main() { int fps = 10; int avenger_score = eng.get_score(); init(); // initialise and then display welcome screen... welcome(); render(); wait(1.0f/fps); // and wait for one frame period while (avenger_score >= 0) { int avenger_score = eng.get_score(); eng.read_input(pad); eng.update(pad); render(); wait(1.0f/fps); } endgame(); } void init() { // need to initialise LCD and Gamepad lcd.init(); pad.init(); // initialise the game with correct ball and paddle sizes eng.init(WALL_WIDTH,WALL_GAP,AVENGER_SIZE,STONE_SIZE,SPEED); } void welcome() { while ( pad.check_event(Gamepad::START_PRESSED) == false) { lcd.clear(); lcd.printString("Eternity Stone",0,1); lcd.refresh(); wait(0.1); } } void render() { // clear screen, re-draw and refresh lcd.clear(); eng.draw(lcd); lcd.refresh(); } void endgame() { lcd.clear(); lcd.printString("Endgame",12,1); lcd.refresh(); pad.tone(587.3,0.9); pad.tone(0.0,0.1); pad.tone(587.3,0.9); pad.tone(0.0,0.1); pad.tone(587.3,0.9); pad.tone(0.0,0.1); pad.tone(698.5,0.6); pad.tone(659.3,0.3); pad.tone(0.0,0.1); pad.tone(659.3,0.6); pad.tone(587.3,0.3); pad.tone(0.0,0.1); pad.tone(554.4,0.6); pad.tone(587.3,0.3); wait(0.1); }