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: mbed FXOS8700CQ mbed-rtos
Diff: Game_two/Character_files/Game_two_cha.cpp
- Revision:
- 21:704d938acf5d
- Parent:
- 14:abe64fe0b6a5
--- a/Game_two/Character_files/Game_two_cha.cpp Mon Apr 22 10:32:40 2019 +0000 +++ b/Game_two/Character_files/Game_two_cha.cpp Sun Apr 28 18:04:23 2019 +0000 @@ -38,18 +38,20 @@ // update y value depending on direction of movement // North is decrement as origin is at the top-left so decreasing moves up - if (d == N) {_y-=_speed;} - else if (d == NE) {_y-=_speed; _x+=_speed;} + if (d == N) {_y-=-_speed*0.7;} + else if (d == NE) {_y-=-_speed*0.7; _x+=_speed;} else if (d == E) {_x+=_speed;} - else if (d == SE) {_y+=_speed; _x+=_speed;} - else if (d == S) {_y+=_speed;} - else if (d == SW) {_y+=_speed; _x-=_speed;} + else if (d == SE) {_y+=-_speed*0.7; _x+=_speed;} + else if (d == S) {_y+=-_speed*0.7;} + else if (d == SW) {_y+=-_speed*0.7; _x-=_speed;} else if (d == W) {_x-=_speed;} - else if (d == NW) {_y-=_speed; _x-=_speed;} + else if (d == NW) {_y-=-_speed*0.7; _x-=_speed;} // check the y origin to ensure that the character doesn't go off screen if (_y < 1) {_y = 1;} if (_y > HEIGHT - 18) {_y = HEIGHT - 18;} + if (_x < 1) {_x = 1;} + if (_x > WIDTH - 18) {_x = WIDTH - 18;} } void Game_two_cha::add_score()