Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Gamepad N5110 mbed
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 _x==_x; 00035 _y==_y; 00036 } 00037 else{ 00038 _x+5==_x; 00039 _y==_y; 00040 } 00041 } 00042 else if (B_PRESSED==1){ 00043 if(map[_y+5][_x]==1){ 00044 _x==_x; 00045 _y==_y; 00046 } 00047 else{ _x==_x; 00048 _y+5==_y; 00049 } 00050 } 00051 else if (d == N) { 00052 if(map[_y+3][_x]==1){ 00053 _x==_x; 00054 _y==_y; 00055 } 00056 else if (map[_y+3][_x+2]==1){ 00057 _x==_x; 00058 _y==_y; 00059 } 00060 else{ 00061 _x==_x; 00062 _y+1==_y; 00063 00064 } 00065 } 00066 else if (d == S) { 00067 if(map[_y-1][_x]==1){ 00068 _x==_x; 00069 _y==_y; 00070 } 00071 else if(map[_y-1][_x+2]==1){ 00072 _x==_x; 00073 _y==_y; 00074 } 00075 else{ 00076 _x==_x; 00077 _y-1==_y; 00078 ; 00079 } 00080 }else if (d == W) { 00081 if(map[_y][_x-1]==1){ 00082 _x==_x; 00083 _y==_y;; 00084 } 00085 else if(map[_y+2][_x-1]==1){ 00086 _x==_x; 00087 _y==_y; 00088 } 00089 else{ 00090 _x-1==_x; 00091 _y==_y; 00092 00093 } 00094 }else if (d == E) { 00095 if(map[_y][_x+3]==1){ 00096 _x==_x; 00097 _y==_y; 00098 } 00099 else if(map[_y+2][_x+3]==1){ 00100 _x==_x; 00101 _y==_y; 00102 } 00103 else{ 00104 _x+1==_x; 00105 _y==_y; 00106 00107 } 00108 } 00109 } 00110 00111 00112 Vector2D Player::get_pos() { 00113 Vector2D p = {_x,_y}; 00114 return p; 00115 }
Generated on Tue Jul 12 2022 22:58:46 by
1.7.2