ELEC2645 (2018/19) / Mbed 2 deprecated el17dg

Dependencies:   mbed

Fork of el17dg by Dmitrijs Griskovs

Revision:
30:d454d0cb72bc
Parent:
29:579e00b7f118
Child:
31:becb8f6bf7b7
diff -r 579e00b7f118 -r d454d0cb72bc menu/menu.cpp
--- a/menu/menu.cpp	Mon Apr 15 12:59:51 2019 +0000
+++ b/menu/menu.cpp	Tue Apr 16 21:16:33 2019 +0000
@@ -3,29 +3,19 @@
 #include "constants.h"
 #include "game.h"
 #include "hud.h"
+#include "models.h"
+#include "gameobject.h"
 
 const int total_options = 3;
 const float time_delay = 100;
 
 Hud highScore;
-
-//MAYBE CHANGE LATER ON.
-int cursor[84] = {
-    0,0,0,0,1,0,0,0,0,0,1,1,
-    0,0,1,1,1,1,0,0,0,1,0,0,
-    0,1,0,0,1,1,1,0,1,0,0,0,
-    1,1,1,1,1,0,1,1,1,0,1,1,
-    0,1,0,0,1,1,1,0,1,0,0,0,
-    0,0,1,1,1,1,0,0,0,1,0,0,
-    0,0,0,0,1,0,0,0,0,0,1,1
-};
-
+GameObject cursor;
 
 Menu::Menu() {                              // NOTE to self: The constructor for declerering intial states of variables.
     current_option = 0;                     // As soon as Menu menu; happens in main, the zero is addressed to the variable.
 }                                           // Another form of declering intial values.
     
-
 bool Menu::updateAndDraw() {                // cheking whether the joystick was moved to point at other options in the menu.
     if(y_dir.read() > joy_threshold_max_y){
         current_option -= 1;
@@ -72,16 +62,16 @@
 }
 
 void Menu::drawPointer(){                         // Checking what option was selected and drawing the pointer
-    int x = 70;                                   // to indicate that postion.
-    int y = 17;
+    cursor.pos.x = 70;                                   // to indicate that postion.
+    cursor.pos.y = 17;
     if (current_option == 0){    
-        y = 17;
+        cursor.pos.y = 17;
     }
     else if (current_option == 1){    
-        y = 25;
+        cursor.pos.y = 25;
     }
     else if (current_option == 2){    
-        y = 32;
+        cursor.pos.y = 32;
     }
-    lcd.drawSprite(x, y, 7, 12, cursor);
+    drawSprite(cursor.pos, menu_cursor_sprite);
 }
\ No newline at end of file