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.
Diff: MazeEngine/MazeEngine.cpp
- Revision:
- 22:745b4d352183
- Parent:
- 21:bcc84d5cb068
- Child:
- 23:6733f8b9c321
--- a/MazeEngine/MazeEngine.cpp Tue May 08 12:20:04 2018 +0000 +++ b/MazeEngine/MazeEngine.cpp Tue May 08 12:55:17 2018 +0000 @@ -18,10 +18,12 @@ void MazeEngine::read_input(Gamepad &pad) { _dir = pad.get_direction(); + // printf("direction %i\n", _dir); } void MazeEngine::update(Gamepad &pad) { + _ball.check_wall_collision(pad); _ball.update(_dir); check_goal(pad); } @@ -34,7 +36,7 @@ // ball _ball.draw(lcd); - + // HERE IS A SIMPLE CODE THAT WHEN THE BALL PASS THROUGH THE OPENING THEN THE SCREEN SHOULD BE CLEARED IN WHICH BRAVO IS PRINTED TO // TELL THE USER THE GAME IS FINISHED. if (ball_pos.x > 83 & ball_pos.y == 27) { @@ -45,15 +47,6 @@ void MazeEngine::check_goal(Gamepad &pad) { ball_pos = _ball.get_pos(); - // WHEN THE BALL REACHES THE Y-AXIS NEEDED WHICH IS 27, THEN THE JOYSTICK FREELY MOVE THE BALL RIGHT THROUGH THE OPENING OF THE SMAZE WALL, - // HOWEVER, IF THE BALL IS NOT EQUAL TO THE Y-AXIS NEEDED, THEN THE BALL MUST BE RESTRICTED TO MOVING SO THAT IT DOES NOT PASS THE WALLS. - if (ball_pos.y == 27) { - if (ball_pos.x > WIDTH) { - ball_pos.x = WIDTH; - } - } else if (ball_pos.x > 80) { - ball_pos.x = 80; - } } void MazeEngine::print_win(N5110 &lcd)