200943373MAZE
Dependencies: mbed
Fork of 200943373MAZE by
Player.cpp
00001 #include "Player.h" 00002 //#include "Background.h" 00003 Player::Player() 00004 { 00005 00006 } 00007 Player::~Player() 00008 { 00009 00010 } 00011 00012 void Player::init(){ 00013 00014 00015 const char array[3][3]={ 00016 {1,1,1}, 00017 {1,1,1}, 00018 {1,1,1}, 00019 }; 00020 00021 _x==2; 00022 _y==2; 00023 00024 00025 } 00026 00027 void Player::update(Direction d,N5110 &lcd,Gamepad &pad) 00028 { 00029 00030 const char map[48][85] = _background.draw(N5110 &lcd); 00031 //Vector2D monsterPos = get_pos(); 00032 if(A_PRESSED==1){ 00033 if(//map[_y][_x+5]==1 00034 ){ 00035 _x==_x; 00036 _y==_y; 00037 } 00038 else{ 00039 _x+5==_x; 00040 _y==_y; 00041 } 00042 } 00043 else if (B_PRESSED==1){ 00044 if(//map[_y+5][_x]==1 00045 ){ 00046 _x==_x; 00047 _y==_y; 00048 } 00049 else{ _x==_x; 00050 _y+5==_y; 00051 } 00052 } 00053 else if (d == N) { 00054 if(//map[_y+3][_x]==1 00055 ){ 00056 _x==_x; 00057 _y==_y; 00058 } 00059 else if (//map[_y+3][_x+2]==1 00060 ){ 00061 _x==_x; 00062 _y==_y; 00063 } 00064 else{ 00065 _x==_x; 00066 _y+1==_y; 00067 00068 } 00069 } 00070 else if (d == S) { 00071 if(//map[_y-1][_x]==1 00072 ){ 00073 _x==_x; 00074 _y==_y; 00075 } 00076 else if(//map[_y-1][_x+2]==1 00077 ){ 00078 _x==_x; 00079 _y==_y; 00080 } 00081 else{ 00082 _x==_x; 00083 _y-1==_y; 00084 ; 00085 } 00086 }else if (d == W) { 00087 if(//map[_y][_x-1]==1 00088 ){ 00089 _x==_x; 00090 _y==_y;; 00091 } 00092 else if(//map[_y+2][_x-1]==1 00093 ){ 00094 _x==_x; 00095 _y==_y; 00096 } 00097 else{ 00098 _x-1==_x; 00099 _y==_y; 00100 00101 } 00102 }else if (d == E) { 00103 if(//map[_y][_x+3]==1 00104 ){ 00105 _x==_x; 00106 _y==_y; 00107 } 00108 else if(//map[_y+2][_x+3]==1 00109 ){ 00110 _x==_x; 00111 _y==_y; 00112 } 00113 else{ 00114 _x+1==_x; 00115 _y==_y; 00116 00117 } 00118 } 00119 } 00120 00121 00122 Vector2D Player::get_pos() { 00123 Vector2D p = {_x,_y}; 00124 return p; 00125 }
Generated on Sat Jul 16 2022 17:21:26 by
1.7.2
