tao lao

Dependencies:   mbed wave_player 4DGL-uLCD-SE MMA8452

Revision:
2:4947d6a82971
Parent:
1:10330bce85cb
Child:
3:33bf11645fe1
--- a/main.cpp	Fri Oct 23 16:18:39 2020 -0400
+++ b/main.cpp	Fri Oct 23 16:30:18 2020 -0400
@@ -1,9 +1,18 @@
-// Projet includes
+//=================================================================
+// The main program file.
+//
+// Copyright 2020 Georgia Tech.  All rights reserved.
+// The materials provided by the instructor in this course are for
+// the use of the students currently enrolled in the course.
+// Copyrighted course materials may not be further disseminated.
+// This file must not be made publicly available anywhere.
+//==================================================================
+
+// Project includes
 #include "globals.h"
 #include "hardware.h"
 #include "map.h"
 #include "graphics.h"
-#include "speech.h"
 #include "snake.h"
 
 #include <math.h>
@@ -11,7 +20,7 @@
 
 #define CITY_HIT_MARGIN 1
 #define CITY_UPPER_BOUND (SIZE_Y-(LANDSCAPE_HEIGHT+MAX_BUILDING_HEIGHT))
-#define FULL_DRAW 1
+
 // Helper function declarations
 void playSound(char* wav);
 
@@ -27,7 +36,24 @@
 Snake snake;
 
 // Function prototypes
+
+/**
+ * Given the game inputs, determine what kind of update needs to happen.
+ * Possible return values are defined below.
+ */
+#define NO_RESULT 0
+#define NO_ACTION 0
+#define ACTION_BUTTON 1
+#define MENU_BUTTON 2
+#define GO_LEFT 3
+#define GO_RIGHT 4
+#define GO_UP 5
+#define GO_DOWN 6
+#define GAME_OVER 7
+#define FULL_DRAW 8
 // Get Actions from User (push buttons & accelerometer)
+// Based on push button and accelerometer inputs, determine which action
+// needs to be performed (may be no action).
 int get_action(GameInputs inputs)
 {
     return 0;
@@ -188,7 +214,7 @@
     ASSERT_P(hardware_init() == ERROR_NONE, "Hardware init failed!");
 
     snake_init(&snake);
-    // Initialize the maps
+    // 0. Initialize the maps -- implement this function:
     maps_init();
     init_main_map();
 
@@ -203,12 +229,21 @@
         Timer t;
         t.start();
 
-        // 1. Read inputs
-
-        // 2. Determine action (move, act, menu, etc.)
-        // 3. Update game
-        // 3b. Check for game over
-        // 4. Draw screen
+        // 1. Read inputs -- implement this function:
+        GameInputs inputs = read_inputs();
+        
+        // 2. Determine action (move, act, menu, etc.) -- implement this function:
+        int action = get_action(inputs);
+        
+        // 3. Update game -- implement this function:
+        int result = update_game(action);
+        
+        // 3b. Check for game over based on result
+        // and if so, handle game over -- implement this.
+                
+        // 4. Draw screen -- provided:
+        draw_game(result);
+        
         // Compute update time
         t.stop();
         int dt = t.read_ms();