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
Diff: engine/main.cpp
- Revision:
- 1:a3c9025e0dad
- Child:
- 2:a48df109588e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/engine/main.cpp Tue Apr 24 10:03:41 2018 +0000 @@ -0,0 +1,100 @@ +/* +ELEC2645 Embedded Systems Project +School of Electronic & Electrical Engineering +University of Leeds +Name: Adam Thompson +Username: el16a2t +Student ID Number: 201047832 +Date: 17/4/18 +*/ +#include "mbed.h" +#include "Gamepad.h" +#include "N5110.h" +#include "sprites.h" +#include "main.h" + + +N5110 lcd(PTC9, PTC0, PTC7, PTD2, PTD1, PTC11); +Gamepad pad; + + + + + +int main() + + +{ + +// initialise the lcd and gamepad + lcd.init(); + lcd.setContrast(0.5); + pad.init (); + +//set initial location conditions for the car + x_player = 24; + y_player = 29; + + while (1) { + + lcd.clear(); + + +//print the player sprite + lcd.drawSprite(x_player,y_player,20,15,(int*) player); +//if L pressed, move player left, if R pressed, move player right + if ( pad.check_event(Gamepad::L_PRESSED) == true) { + + x_player = x_player-20; + } + if (x_player <4) { + x_player = 4; + } + if ( pad.check_event(Gamepad::R_PRESSED) == true) { + + x_player = x_player+20; + } + if (x_player >44) { + x_player = 44; + } + +//print road lines + lcd.drawRect(1,1,1,1500,FILL_BLACK); + + lcd.drawRect(21,1,1,1500,FILL_BLACK); + + lcd.drawRect(41,1,1,1500,FILL_BLACK); + + lcd.drawRect(61,1,1,1500,FILL_BLACK); + // l1.MoveTo (1,1); + // l1.LineTo (1,50); + +//display score + score = 1; + score = score++; + + // lcd.printChar (score*read_pot(), 25,20); + +//cars move down the road + x_car = 24; + y_car = 1; + + y_car = y_car+1; + + + + lcd.refresh(); + wait(0.05); + + + + + + + + } + + + + +}