Final Commit

Dependencies:   mbed

Revision:
25:f03439ee32c6
Parent:
21:63c5590cb2c2
Child:
26:23301f48c1ed
--- a/main.cpp	Tue May 01 12:20:42 2018 +0000
+++ b/main.cpp	Tue May 08 10:52:12 2018 +0000
@@ -5,12 +5,19 @@
 #include "Testing.h"
 #include "SnakeEngine.h"
 
+
+
 #define FOOD_X 20
 #define FOOD_Y 20
 #define SNAKE_P_X 42
 #define SNAKE_P_Y 24
 #define IN E
 #define CUR E
+#define SPAWN_TIME 200
+
+#ifndef WITH_TESTING
+#include "tests.h"
+//#endif
 
 struct UserInput 
 {
@@ -36,29 +43,36 @@
 Gamepad pad;
 Snake snake;
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
-Testing test1;
+//Testing test1;
 
 // ----- Prototypes -----
 
 void init();
 void update_game(UserInput input);
 void render();
-void start_menu();
+void start_screen();
 
 int main() {
         
+//#ifdef WITH_TESTING
+    int number_of_failures = run_tests();
+
+    if(number_of_failures > 0) return number_of_failures;
+#endif
         init();
+        start_screen();
         render();
         
         wait(0.2); 
               
         while(1) {
-        
+         
+         
          snake_engine.get_input(pad);
          snake_engine.update(pad);
          render();
 
-         wait(0.2); 
+         wait(0.15); 
          
     }
     }
@@ -71,7 +85,7 @@
     pad.init();
      
     // initialise the game with food, snake...
-    snake_engine.init(IN, CUR, SNAKE_P_X, SNAKE_P_Y);
+    snake_engine.init(IN, CUR, SNAKE_P_X, SNAKE_P_Y, SPAWN_TIME);
 
 }
 
@@ -85,8 +99,37 @@
     
 }
 
-void start_menu() 
+void start_screen() 
 {
-    
-    
+    int i = 0;
+    lcd.setContrast(0.5);
+    for(i = 0; i <= 4; ++i) {
+        
+        lcd.printString("   NOTENDO    ", 0,i);
+        lcd.refresh();
+        wait(0.3);
+        lcd.clear();        
+
+        
+        if(i == 4) {
+            
+            lcd.printString("   NOTENDO    ", 0,5);
+            lcd.refresh();     
+            pad.tone(0,1.75);
+            wait(1.5);
+            lcd.clear();
+            
+            }
+        
+        }
+        
+    while ( pad.check_event(Gamepad::START_PRESSED) == false ) {
+        
+        
+        lcd.printString("   Welcome      ", 0, 1);
+        lcd.printString(" Press Start    ", 0, 3);
+        lcd.refresh();
+        
+        }
+        
 }
\ No newline at end of file