Yang Zhenye 201199680
Dependencies: mbed
Diff: Roony/Roony.cpp
- Revision:
- 3:30c81344beff
- Parent:
- 2:baca89f466bc
--- a/Roony/Roony.cpp Thu Apr 30 07:08:09 2020 +0000 +++ b/Roony/Roony.cpp Fri May 08 09:09:49 2020 +0000 @@ -27,21 +27,21 @@ }; void player::init(){ - _x=38; - _y=5; + _player_x=38; + _player_y=5; } void player::set_palyer_x(float joy_x int speed) { _speed=speed; if (joy_x < float(-0.5){ _speed=-0.5; - _x=38+_speed; + _player_x=38+_speed; else if (x<=0){ _speed = 0 } } if (joy_x > float(0.5){ _speed=0.5; - _x=38+_speed; + _player_x=38+_speed; else if (x>=80){ _speed = 0 } @@ -53,7 +53,11 @@ unsigned int const y1, FullBlack) { -bool player::collisicon_flag() {} +bool player::collisicon_flag() { + if ((_player_x == _x() - 2) && (_player_y == _y() - 5)) { + _collision_flag = true; + _player_score++; + } int * player::get_form(roonybody){ if (roonybody == left){ return *left} @@ -61,12 +65,12 @@ return *right} else if (ronnybody == stand){ return *stand} -lcd.drawSprite(_x, _y, 5, 10, (int *)get_form(ronnybody)); +lcd.drawSprite(_player_x, _player_y, 5, 10, (int *)get_form(ronnybody)); int player::get_x(){ - return _x; + return _player_x; } int player::get_y(){ - return _y; + return _player_y; } int player::get_speed(){ return _speed;