200943373MAZE

Dependencies:   mbed

Fork of 200943373MAZE by hongyun AHN

Player/Player.cpp

Committer:
hongyunAHN
Date:
2017-05-04
Revision:
0:df4347043adf
Child:
1:bd92ef8d00ac

File content as of revision 0:df4347043adf:

#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;    
}