Final Submission. I have read and agreed with Statement of Academic Integrity.

Dependencies:   mbed Gamepad N5110 Joystick

Revision:
2:0bd6711eae26
Parent:
1:b9f3b7d869d8
Child:
3:660de4311976
--- a/Game_engine/Game_engine.cpp	Wed May 08 19:32:05 2019 +0000
+++ b/Game_engine/Game_engine.cpp	Wed May 08 21:26:27 2019 +0000
@@ -1,11 +1,44 @@
 #include "Game_engine.h"
+#include "Snake.h"
 
 GameEngine::GameEngine() {
 }
 
 GameEngine::~GameEngine() {
 }
+Snake snake;
 
+void GameEngine::init() {
+    snake.init();
+}
 void GameEngine::draw(N5110 &lcd) {    
     lcd.drawRect(0,0,WIDTH,HEIGHT,FILL_TRANSPARENT); // Draws screen limits
+    snake.draw_head(lcd);
+}
+
+void GameEngine::get_dir(Gamepad &gamepad) {
+    if ( gamepad.check_event(Gamepad::Y_PRESSED) ) {
+        _direction = 0;
+    }
+    if ( gamepad.check_event(Gamepad::A_PRESSED) ) {
+        _direction = 1;
+    }
+    if ( gamepad.check_event(Gamepad::X_PRESSED) ) {
+        _direction = 2;
+    }
+    if ( gamepad.check_event(Gamepad::B_PRESSED) ) {
+        _direction = 3;
+    }
+}
+
+void GameEngine::snake_move() {
+    if (_direction == 0) {
+        snake.set_snake_posY (snake.get_snake_posY()- 4);    
+    } else if (_direction == 1) {
+        snake.set_snake_posY (snake.get_snake_posY()+ 4);   
+    } else if (_direction == 2) {
+        snake.set_snake_posX (snake.get_snake_posX()- 4); 
+    } else if (_direction == 3) {
+        snake.set_snake_posX (snake.get_snake_posX()+ 4); 
+    }    
 }
\ No newline at end of file