200943373MAZE
Dependencies: Gamepad N5110 mbed
Diff: Player/Player.cpp
- Revision:
- 0:df4347043adf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Player/Player.cpp Thu May 04 11:25:43 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