ELEC2645 (2018/19) / Mbed 2 deprecated el17set_

Dependencies:   mbed

Revision:
5:e6cb6fda5b37
Parent:
1:dc1b2f4b72be
Child:
8:bf4f93602b8b
Child:
9:b272864b8355
--- a/main.cpp	Thu Mar 21 14:24:35 2019 +0000
+++ b/main.cpp	Tue Apr 23 16:03:34 2019 +0000
@@ -1,50 +1,51 @@
-/*
-ELEC2645 Embedded Systems Project
-School of Electronic & Electrical Engineering
-University of Leeds
-Name: Spencer Tingle
-Username: el17set
-Student ID Number: 201147893
-Date: 21/03/2019
-*/
-
-#include "mbed.h"
-#include "Gamepad.h"
-#include "N5110.h"
-#include "Smiley.h"
-
-N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Gamepad pad;
-Smiley smiley;
-
-void init();
-void render();
-
-int main(){
-    
-    int fps = 8;
-
-    init();
-    
-    render();
-    wait(1.0f/fps);
-
-    while (1) {
-        render();
-        wait(1.0f/fps);
-    }
-
-}
-
-    void init(){
-    
-    lcd.init();
-    pad.init();
-    }
-    
-    void render(){
-    
-    lcd.clear();  
-    smiley.drawSprite(lcd);
-    lcd.refresh();
-    }
\ No newline at end of file
+#include "mbed.h"
+#include "Gamepad.h"
+#include "N5110.h"
+#include "Game.h"
+
+struct joystick_val {
+    Direction dir;
+    float mag;
+};
+
+Game game;
+N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
+Gamepad pad;
+
+void init();
+void inputs(joystick_val input);
+void render();
+void start_screen();
+
+int main(){
+    int fps = 6;
+    init();
+    start_screen(); 
+    render();    
+    wait(1.0f/fps);
+      
+    while (1) {
+        render();
+        game.dirmag(pad);
+        game.movement(pad);
+        wait(1.0f/fps);
+    }
+    
+}
+    
+void init(){
+    lcd.init();
+    pad.init();
+    game.init();
+}
+    
+void render(){
+    lcd.clear();
+    game.drawSprite(lcd);
+    lcd.refresh();
+}
+    
+void start_screen(){
+    lcd.printString("   | Life |   ",0,0);
+    lcd.printString(" Press Start to be Born ",0,0);
+}
\ No newline at end of file