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:
- weiway
- Date:
- 2018-05-07
- Revision:
- 15:47ea86f1ed70
- Parent:
- 13:4026781772cb
- Child:
- 18:e58a1f8e72ad
File content as of revision 15:47ea86f1ed70:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Wei Wei
Username: el15ww
Student ID Number: 200975452
Date:
*/
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "snake_engine.h"
#include "snake.h"
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
snake_engine engine;
void init();
void render();
void welcome();
void reset();
struct UserInput {
Direction d;
float mag;
};
int main()
{
init();
welcome();
while (1) {
engine.read_input(pad);
engine.update(pad, lcd);
render();
wait(0.05f);
reset();
}
}
void init()
{
lcd.init();
pad.init();
engine.init();
}
void render()
{
lcd.clear();
engine.draw(lcd);
lcd.refresh();
}
void welcome()
{
lcd.printString(" Simple ",0,1);
lcd.printString("Snake Game",0,2);
lcd.printString(" WEI WEI ",0,3);
lcd.printString("200975452",0,4);
lcd.printString(" PRESS START ",0,5);
lcd.refresh();
lcd.clear();
wait(0.5);
while ( pad.check_event(Gamepad::START_PRESSED) == false) {
}
}
void reset()
{
if ( pad.check_event(Gamepad::BACK_PRESSED) == true) {
lcd.clear();
lcd.refresh();
init();
welcome();
}
}