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.
Diff: main.cpp
- Revision:
- 0:07c4fef6c0af
- Child:
- 1:538386e72e40
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed May 08 21:44:02 2019 +0000
@@ -0,0 +1,83 @@
+/*
+ELEC2645 Embedded Systems Project
+School of Electronic & Electrical Engineering
+University of Leeds
+
+Name: Jiaxin Zhou
+Username: Jiaxin Zhou
+Student ID Number: 201282650
+Date:16/04/2019
+
+*/
+
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+#include "Move.h"
+#include "Menu.h"
+
+
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+Move move;
+Menu menu;
+
+void initial();
+void welcome();
+void render();
+void menus(N5110 &lcd);
+int input(int sel,Gamepad &pad);
+
+
+int main () {
+ int fps = 1;
+ initial();
+ welcome();
+ menu.menus(lcd,pad);
+ fps = menu.difficulty(lcd,pad);
+ render();
+ move.getfood();
+ while(1) {
+ //process_input();
+ //update_game_state();
+ //refresh_display();
+ //wait_ms(1000/fps);
+ move.eatfood();
+ move.update(pad);
+ move.updatebody();
+
+ render();
+ move.die(lcd,pad);
+ wait(1.0f/fps);
+ }
+
+
+}
+
+void initial() {
+ lcd.init();
+ pad.init();
+ move.initial();
+}
+
+void render()
+{
+ // clear screen, re-draw and refresh
+ lcd.clear();
+ move.onlcd(lcd);
+ lcd.refresh();
+}
+
+void welcome() {
+ lcd.printString(" snake! ",0,1);
+ lcd.printString(" Press Start ",0,4);
+ lcd.refresh();
+
+ while ( pad.check_event(Gamepad::START_PRESSED) == false) {
+ pad.leds_on();
+ wait(0.1);
+ pad.leds_off();
+ wait(0.1);
+ }
+
+}
\ No newline at end of file