Final Commit

Dependencies:   mbed

Committer:
JRM1986
Date:
Wed Mar 21 13:09:20 2018 +0000
Revision:
7:c38800a428a6
Parent:
6:f3f508cea1c4
Child:
8:a2b431b9b3f7
Initialisation of Food class completed, de-bugged but not tested with testing class;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JRM1986 3:50f01159c61d 1 #include "mbed.h"
JRM1986 3:50f01159c61d 2 #include "FXOS8700CQ.h"
JRM1986 3:50f01159c61d 3 #include "Gamepad.h"
JRM1986 3:50f01159c61d 4 #include "N5110.h"
JRM1986 5:27fcb9b36e7e 5 #include "Testing.h"
JRM1986 6:f3f508cea1c4 6 #include "SnakeEngine.h"
JRM1986 6:f3f508cea1c4 7
JRM1986 7:c38800a428a6 8 #define FOOD_X 10
JRM1986 7:c38800a428a6 9 #define FOOD_Y 10
JRM1986 7:c38800a428a6 10
JRM1986 6:f3f508cea1c4 11 struct UserInput
JRM1986 6:f3f508cea1c4 12 {
JRM1986 6:f3f508cea1c4 13
JRM1986 6:f3f508cea1c4 14 Direction d;
JRM1986 6:f3f508cea1c4 15
JRM1986 6:f3f508cea1c4 16 };
JRM1986 6:f3f508cea1c4 17
JRM1986 0:53ee0f689634 18 /*
JRM1986 0:53ee0f689634 19 ELEC2645 Embedded Systems Project
JRM1986 7:c38800a428a6 20 School of Electronic & Electrical Engineering
JRM1986 0:53ee0f689634 21 University of Leeds
JRM1986 0:53ee0f689634 22 Name: Joshua Robert Marshall
JRM1986 0:53ee0f689634 23 Username: ll13jrm
JRM1986 0:53ee0f689634 24 Student ID Number: 200764543
JRM1986 0:53ee0f689634 25 Date: 28/02/2018
JRM1986 3:50f01159c61d 26 */
JRM1986 3:50f01159c61d 27
JRM1986 6:f3f508cea1c4 28 // ----- Objects -----
JRM1986 6:f3f508cea1c4 29
JRM1986 6:f3f508cea1c4 30 SnakeEngine snake_engine;
JRM1986 6:f3f508cea1c4 31 Gamepad pad;
JRM1986 6:f3f508cea1c4 32 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
JRM1986 5:27fcb9b36e7e 33 Testing test;
JRM1986 3:50f01159c61d 34
JRM1986 6:f3f508cea1c4 35 // ----- Prototypes -----
JRM1986 6:f3f508cea1c4 36
JRM1986 6:f3f508cea1c4 37 void init();
JRM1986 6:f3f508cea1c4 38 void update_game(UserInput input);
JRM1986 6:f3f508cea1c4 39 void render();
JRM1986 6:f3f508cea1c4 40 void start_menu();
JRM1986 6:f3f508cea1c4 41
JRM1986 3:50f01159c61d 42 int main() {
JRM1986 3:50f01159c61d 43
JRM1986 7:c38800a428a6 44 while(1) {
JRM1986 6:f3f508cea1c4 45
JRM1986 7:c38800a428a6 46 printf("Nothing");
JRM1986 5:27fcb9b36e7e 47
JRM1986 5:27fcb9b36e7e 48 }
JRM1986 6:f3f508cea1c4 49 }
JRM1986 3:50f01159c61d 50
JRM1986 6:f3f508cea1c4 51 // initialies all classes and libraries
JRM1986 6:f3f508cea1c4 52 void init()
JRM1986 6:f3f508cea1c4 53 {
JRM1986 6:f3f508cea1c4 54 // need to initialise LCD and Gamepad
JRM1986 6:f3f508cea1c4 55 lcd.init();
JRM1986 6:f3f508cea1c4 56 pad.init();
JRM1986 6:f3f508cea1c4 57
JRM1986 6:f3f508cea1c4 58 // initialise the game with food, snake...
JRM1986 7:c38800a428a6 59 snake_engine.init(FOOD_X, FOOD_Y);
JRM1986 6:f3f508cea1c4 60
JRM1986 6:f3f508cea1c4 61 }
JRM1986 6:f3f508cea1c4 62
JRM1986 6:f3f508cea1c4 63 // this function draws each frame on the LCD
JRM1986 6:f3f508cea1c4 64 void render()
JRM1986 6:f3f508cea1c4 65 {
JRM1986 6:f3f508cea1c4 66 // clear screen, re-draw and refresh
JRM1986 6:f3f508cea1c4 67 lcd.clear();
JRM1986 6:f3f508cea1c4 68 // snake_engine.draw(lcd);
JRM1986 6:f3f508cea1c4 69 lcd.refresh();
JRM1986 6:f3f508cea1c4 70 }
JRM1986 6:f3f508cea1c4 71
JRM1986 6:f3f508cea1c4 72 void start_menu() {
JRM1986 6:f3f508cea1c4 73
JRM1986 6:f3f508cea1c4 74 // brings up start menu, levels, scores
JRM1986 6:f3f508cea1c4 75
JRM1986 6:f3f508cea1c4 76 }