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 FATFileSystem
Diff: GolfEngine/GolfEngine.cpp
- Revision:
- 5:0b31909caf7f
- Child:
- 6:747335f697d6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GolfEngine/GolfEngine.cpp Wed Apr 17 10:27:09 2019 +0000 @@ -0,0 +1,41 @@ +#include "GolfEngine.h" + +void GolfEngine::init() +{ + _x_pos = 24; + _y_pos = 32; + _ball.init(_x_pos, _y_pos); + + Course _level_1[6] = { //first coord start second end + {LEFT,{9,26},{9,40}}, //top to bottom + {BOTTOM,{9,40},{74,40}}, //left to right + {RIGHT,{74,9},{9,40}}, //top to bottom + {TOP,{50,9},{74,9}}, //left to right + {LEFT,{50,9},{50,26}}, //top to bottom + {TOP,{9,26},{50,26}} //left to right + }; +} + +void GolfEngine::drawGame(N5110 &lcd) +{ + _ball.drawBall(lcd); + _ball.printShotCount(lcd); + drawCourseWalls(lcd); +} + +void GolfEngine::update_ball(Gamepad &pad, int frame_rate) +{ + + _ball.shoot_ball(pad); + _ball.check_wall_bounce(); + _ball.move_ball(frame_rate); + _ball.check_wall_bounce(); +} + +void GolfEngine::drawCourseWalls(N5110 &lcd) +{ + for(int i = 0; i > 5; i++) { + lcd.drawLine(_level_1[i].start.x,_level_1[i].start.y,_level_1[i].end.x,_level_1[i].end.y,1); //draws line for each wall in course + } +} +