Final Commit

Dependencies:   mbed

Committer:
JRM1986
Date:
Fri Mar 16 13:02:55 2018 +0000
Revision:
6:f3f508cea1c4
Parent:
5:27fcb9b36e7e
Child:
7:c38800a428a6
Basic functions for main, and SnakeEngine introduced but not defined

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 6:f3f508cea1c4 8 struct UserInput
JRM1986 6:f3f508cea1c4 9 {
JRM1986 6:f3f508cea1c4 10
JRM1986 6:f3f508cea1c4 11 Direction d;
JRM1986 6:f3f508cea1c4 12
JRM1986 6:f3f508cea1c4 13 };
JRM1986 6:f3f508cea1c4 14
JRM1986 0:53ee0f689634 15 /*
JRM1986 0:53ee0f689634 16 ELEC2645 Embedded Systems Project
JRM1986 0:53ee0f689634 17 School
JRM1986 0:53ee0f689634 18 of Electronic & Electrical Engineering
JRM1986 0:53ee0f689634 19 University of Leeds
JRM1986 0:53ee0f689634 20 Name: Joshua Robert Marshall
JRM1986 0:53ee0f689634 21 Username: ll13jrm
JRM1986 0:53ee0f689634 22 Student ID Number: 200764543
JRM1986 0:53ee0f689634 23 Date: 28/02/2018
JRM1986 3:50f01159c61d 24 */
JRM1986 3:50f01159c61d 25
JRM1986 6:f3f508cea1c4 26 // ----- Objects -----
JRM1986 6:f3f508cea1c4 27
JRM1986 6:f3f508cea1c4 28 SnakeEngine snake_engine;
JRM1986 6:f3f508cea1c4 29 Gamepad pad;
JRM1986 6:f3f508cea1c4 30 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
JRM1986 5:27fcb9b36e7e 31 Testing test;
JRM1986 3:50f01159c61d 32
JRM1986 6:f3f508cea1c4 33 // ----- Prototypes -----
JRM1986 6:f3f508cea1c4 34
JRM1986 6:f3f508cea1c4 35 void init();
JRM1986 6:f3f508cea1c4 36 void update_game(UserInput input);
JRM1986 6:f3f508cea1c4 37 void render();
JRM1986 6:f3f508cea1c4 38 void start_menu();
JRM1986 6:f3f508cea1c4 39
JRM1986 3:50f01159c61d 40 int main() {
JRM1986 3:50f01159c61d 41
JRM1986 6:f3f508cea1c4 42 // ----- Testing Program -----
JRM1986 3:50f01159c61d 43 while(1){
JRM1986 6:f3f508cea1c4 44
JRM1986 6:f3f508cea1c4 45
JRM1986 5:27fcb9b36e7e 46 if(test.food_test_position()) {
JRM1986 5:27fcb9b36e7e 47
JRM1986 5:27fcb9b36e7e 48 printf("Passed position test \n");
JRM1986 5:27fcb9b36e7e 49
JRM1986 5:27fcb9b36e7e 50 }
JRM1986 5:27fcb9b36e7e 51
JRM1986 5:27fcb9b36e7e 52 else {
JRM1986 5:27fcb9b36e7e 53
JRM1986 5:27fcb9b36e7e 54 printf("Failed position test \n");
JRM1986 5:27fcb9b36e7e 55
JRM1986 5:27fcb9b36e7e 56 }
JRM1986 5:27fcb9b36e7e 57
JRM1986 5:27fcb9b36e7e 58 if(test.food_test_range()) {
JRM1986 5:27fcb9b36e7e 59
JRM1986 5:27fcb9b36e7e 60 printf("Passed Range Test \n");
JRM1986 5:27fcb9b36e7e 61
JRM1986 5:27fcb9b36e7e 62 }
JRM1986 5:27fcb9b36e7e 63
JRM1986 5:27fcb9b36e7e 64 else {
JRM1986 5:27fcb9b36e7e 65
JRM1986 5:27fcb9b36e7e 66 printf("Failed Range Test \n");
JRM1986 5:27fcb9b36e7e 67
JRM1986 5:27fcb9b36e7e 68 }
JRM1986 6:f3f508cea1c4 69
JRM1986 6:f3f508cea1c4 70 wait(1.0);
JRM1986 3:50f01159c61d 71
JRM1986 3:50f01159c61d 72 }
JRM1986 6:f3f508cea1c4 73
JRM1986 6:f3f508cea1c4 74 }
JRM1986 3:50f01159c61d 75
JRM1986 6:f3f508cea1c4 76 // initialies all classes and libraries
JRM1986 6:f3f508cea1c4 77 void init()
JRM1986 6:f3f508cea1c4 78 {
JRM1986 6:f3f508cea1c4 79 // need to initialise LCD and Gamepad
JRM1986 6:f3f508cea1c4 80 lcd.init();
JRM1986 6:f3f508cea1c4 81 pad.init();
JRM1986 6:f3f508cea1c4 82
JRM1986 6:f3f508cea1c4 83 // initialise the game with food, snake...
JRM1986 6:f3f508cea1c4 84 // snake_engine.init( );
JRM1986 6:f3f508cea1c4 85
JRM1986 6:f3f508cea1c4 86 }
JRM1986 6:f3f508cea1c4 87
JRM1986 6:f3f508cea1c4 88 // this function draws each frame on the LCD
JRM1986 6:f3f508cea1c4 89 void render()
JRM1986 6:f3f508cea1c4 90 {
JRM1986 6:f3f508cea1c4 91 // clear screen, re-draw and refresh
JRM1986 6:f3f508cea1c4 92 lcd.clear();
JRM1986 6:f3f508cea1c4 93 // snake_engine.draw(lcd);
JRM1986 6:f3f508cea1c4 94 lcd.refresh();
JRM1986 6:f3f508cea1c4 95 }
JRM1986 6:f3f508cea1c4 96
JRM1986 6:f3f508cea1c4 97 void start_menu() {
JRM1986 6:f3f508cea1c4 98
JRM1986 6:f3f508cea1c4 99 // brings up start menu, levels, scores
JRM1986 6:f3f508cea1c4 100
JRM1986 6:f3f508cea1c4 101 }