Dependencies:   mbed

Revision:
25:f03439ee32c6
Parent:
24:4b180348826e
Child:
26:23301f48c1ed
--- a/SnakeEngine/SnakeEngine.h	Tue May 01 12:20:42 2018 +0000
+++ b/SnakeEngine/SnakeEngine.h	Tue May 08 10:52:12 2018 +0000
@@ -18,21 +18,31 @@
 int g_tail_length();
 Vector2D g_tail_position();
 
+void g_frame_time(int frame_time);
+
 int g_get_even_array();
 int g_get_odd_array();
 int g_get_engine_frame_count();
 
 static Vector2D g_tp;
-static int g_tl;
-static int g_tc;
-static int g_engine_fc;
 
-static int g_odd_array_x[100];
-static int g_odd_array_y[100];
-static int g_even_array_x[100];
-static int g_even_array_y[100];
-static int g_array_x[100];
-static int g_array_y[100];
+static int g_tl; // tail length
+//static int g_tc; // 
+static int g_engine_fc; // frame counter for draw tail functions
+static int g_ft; // frame counter for decreasing time between food spawning
+static int g_n; // ensures spawning of food occurs periodically
+static bool g_wall; // wall collision detected
+    
+/** Returns the speed 
+*/
+static double g_speed;
+
+static int g_odd_array_x[100]; // array to store odd values for x component of tail segments
+static int g_odd_array_y[100]; // array to store odd values for y component of tail segments
+static int g_even_array_x[100]; // array to store even values for x component of tail segments
+static int g_even_array_y[100]; // array to store even values for y component of tail segments
+//static int g_array_x[100];
+//static int g_array_y[100];
 
 Vector2D g_holder_pos();
 
@@ -52,10 +62,11 @@
     * @param Input direction from pad
     * @param Current direction of snake
     * @param pos_x x position
-    * @param pos_y y position   
+    * @param pos_y y position
+    * @param sets initial number of frames between food spawning   
     */
     
-    void init(Direction in, Direction cur, int pos_x, int pos_y); 
+    void init(Direction in, Direction cur, int pos_x, int pos_y, int n_frames); 
     
     /** Updates the Food and Snake classes from the Gamepad 
     */
@@ -125,6 +136,21 @@
     */
     
     void set_even_array(Gamepad &pad);
+    
+    /** Decreses the amount of frames between spawning of food
+    * @param determines the interval and amount of tail segments are reached
+             before the time between spawning reduces   
+    */
+    
+    int food_spawning_time(int frame_decrementer);
+    
+    /** Changes the frame rate increasing speed
+    * @param determines much food is eaten before increasing the speed
+    * @param defines the increase in speed
+    */
+    
+    void increase_speed(int resetter, float speed_decrementer);
+
         
 private:
 
@@ -141,19 +167,15 @@
     Direction _cur;
     
     bool _collision;
-    
-    static int _odd_array_x[100];
-    static int _odd_array_y[100];
-    static int _even_array_x[100];
-    static int _even_array_y[100];
-    int _array_x[100];
-    int _array_y[100];
+    int _n_frames;
     
     int _tail_x;
     int _tail_y;
     
     int _number_food_frames;
     
+    void _wall_col_isr();
+    
 
 };
 #endif
\ No newline at end of file