Game codes for Pokemon Academy Yiu Fai Kwok - 201198802 I have read the University Regulations on Plagiarism and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources.
Dependencies: mbed FXOS8700CQ mbed-rtos
Diff: Game_two/Character_files/Game_two_cha.cpp
- Revision:
- 21:704d938acf5d
- Parent:
- 14:abe64fe0b6a5
- Child:
- 33:f7ec806e14b6
--- 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()