copy

Dependencies:   Gamepad N5110 mbed

Revision:
0:ffd6b3f45a8c
diff -r 000000000000 -r ffd6b3f45a8c Player/Player.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Player/Player.cpp	Wed May 03 22:37:17 2017 +0000
@@ -0,0 +1,115 @@
+#include "Player.h"
+#include "Background.h"
+Player::Player()
+{
+
+}
+Player::~Player()
+{
+
+}
+
+void Player::init(){
+
+ 
+    const char array[3][3]={
+        {1,1,1},
+        {1,1,1},
+        {1,1,1},
+    };
+
+     _x==2;
+     _y==2;
+      
+
+}
+
+void Player::update(Direction d,N5110 &lcd,Gamepad &pad)
+{
+  
+    const char map[48][85] = _background.draw(N5110 &lcd);
+    Vector2D monsterPos = get_pos();
+    if(A_PRESSED==1){
+        if(map[_y][_x+5]==1){
+            _x==_x;
+            _y==_y;
+            }
+        else{
+            _x+5==_x;
+            _y==_y;
+            }
+    }
+    else if (B_PRESSED==1){
+        if(map[_y+5][_x]==1){
+              _x==_x;
+              _y==_y;
+            }
+        else{ _x==_x;
+              _y+5==_y;
+            }
+        }
+    else if (d == N) { 
+        if(map[_y+3][_x]==1){
+              _x==_x;
+              _y==_y;
+        }
+        else if (map[_y+3][_x+2]==1){
+             _x==_x;
+            _y==_y;
+        }      
+        else{ 
+             _x==_x;
+              _y+1==_y;
+          
+        }
+    } 
+    else if (d == S) {
+        if(map[_y-1][_x]==1){
+             _x==_x;
+             _y==_y;
+        }
+        else if(map[_y-1][_x+2]==1){
+              _x==_x;
+              _y==_y; 
+        }
+        else{   
+               _x==_x;
+              _y-1==_y;
+         ;
+        }   
+    }else if (d == W) {
+        if(map[_y][_x-1]==1){
+              _x==_x;
+              _y==_y;;    
+        }
+        else if(map[_y+2][_x-1]==1){
+              _x==_x;
+              _y==_y;
+        }    
+        else{
+             _x-1==_x;
+              _y==_y;
+           
+        }  
+    }else if (d == E) {
+        if(map[_y][_x+3]==1){
+              _x==_x;
+              _y==_y;
+        }
+        else if(map[_y+2][_x+3]==1){
+              _x==_x;
+              _y==_y;
+        }
+        else{
+             _x+1==_x;
+             _y==_y;
+            
+        }   
+    }
+}
+
+
+Vector2D Player::get_pos() {
+    Vector2D p = {_x,_y};
+    return p;    
+}
\ No newline at end of file