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:
- sdlashmar
- Date:
- 2020-05-22
- Revision:
- 10:3958fb08696d
- Parent:
- 9:f0213e632379
- Child:
- 12:cb3a81adf48b
File content as of revision 10:3958fb08696d:
/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
2019/20
Name:Samuel Lashmar
Username:el17sdl
Student ID Number:201170334
Date:04/03/20
*/
// includes
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "SnakeHead.h"
#include "SnakeTail.h"
#include "GameEngine.h"
// objects
Gamepad pad;
N5110 lcd;
SnakeHead head;
SnakeTail tail;
GameEngine engine;
//
#define HEAD_SIZE 1
#define HEAD_SPEED 2
void welcome();
void init();
int main()
{
int fps = 6;
//initialise objects
init();
engine.init(HEAD_SIZE, HEAD_SPEED);
//head.init(1,3);
//render first frame
welcome();
wait(3.0);
lcd.clear();
//head.draw(lcd);
lcd.refresh();
while(1) {
/*
if (_d == N) {
printf("North\n");
} else if (_d == NE) {
printf("North East\n");
} else if (_d == E) {
printf("East\n");
} else if (_d == SE) {
printf("South East\n");
} else if (_d == S) {
printf("South\n");
} else if (_d == SW) {
printf("South West\n");
} else if (_d == W) {
printf("West\n");
} else if (_d == NW) {
printf("North West\n");
} else {
printf("Centre\n");
};*/
/*if (pad.A_pressed() == true) {
printf("start pressed\n");
} else if (pad.A_pressed() == false) {
printf("start not pressed\n");
}*/
engine.read_input(pad);
engine.update(pad, lcd);
lcd.clear();
engine.draw(lcd);
lcd.refresh();
wait(1.0f/fps);
}
}
void welcome() {
lcd.printString(" SNAKE! ",0,1);
lcd.refresh();
/* wait flashing LEDs until start button is pressed (start pressed function does not seem ot be working as expected
while ( pad.start_pressed() == false) {
lcd.setContrast( pad.read_pot1());
pad.leds_on();
wait(0.1);
pad.leds_off();
wait(0.1);
} */
}
void init() {
lcd.init();
pad.init();
}