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
GolfEngine/GolfEngine.cpp@5:0b31909caf7f, 2019-04-17 (annotated)
- Committer:
- ellisbhastroud
- Date:
- Wed Apr 17 10:27:09 2019 +0000
- Revision:
- 5:0b31909caf7f
- Child:
- 6:747335f697d6
Levels Added Not functioning
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ellisbhastroud | 5:0b31909caf7f | 1 | #include "GolfEngine.h" |
ellisbhastroud | 5:0b31909caf7f | 2 | |
ellisbhastroud | 5:0b31909caf7f | 3 | void GolfEngine::init() |
ellisbhastroud | 5:0b31909caf7f | 4 | { |
ellisbhastroud | 5:0b31909caf7f | 5 | _x_pos = 24; |
ellisbhastroud | 5:0b31909caf7f | 6 | _y_pos = 32; |
ellisbhastroud | 5:0b31909caf7f | 7 | _ball.init(_x_pos, _y_pos); |
ellisbhastroud | 5:0b31909caf7f | 8 | |
ellisbhastroud | 5:0b31909caf7f | 9 | Course _level_1[6] = { //first coord start second end |
ellisbhastroud | 5:0b31909caf7f | 10 | {LEFT,{9,26},{9,40}}, //top to bottom |
ellisbhastroud | 5:0b31909caf7f | 11 | {BOTTOM,{9,40},{74,40}}, //left to right |
ellisbhastroud | 5:0b31909caf7f | 12 | {RIGHT,{74,9},{9,40}}, //top to bottom |
ellisbhastroud | 5:0b31909caf7f | 13 | {TOP,{50,9},{74,9}}, //left to right |
ellisbhastroud | 5:0b31909caf7f | 14 | {LEFT,{50,9},{50,26}}, //top to bottom |
ellisbhastroud | 5:0b31909caf7f | 15 | {TOP,{9,26},{50,26}} //left to right |
ellisbhastroud | 5:0b31909caf7f | 16 | }; |
ellisbhastroud | 5:0b31909caf7f | 17 | } |
ellisbhastroud | 5:0b31909caf7f | 18 | |
ellisbhastroud | 5:0b31909caf7f | 19 | void GolfEngine::drawGame(N5110 &lcd) |
ellisbhastroud | 5:0b31909caf7f | 20 | { |
ellisbhastroud | 5:0b31909caf7f | 21 | _ball.drawBall(lcd); |
ellisbhastroud | 5:0b31909caf7f | 22 | _ball.printShotCount(lcd); |
ellisbhastroud | 5:0b31909caf7f | 23 | drawCourseWalls(lcd); |
ellisbhastroud | 5:0b31909caf7f | 24 | } |
ellisbhastroud | 5:0b31909caf7f | 25 | |
ellisbhastroud | 5:0b31909caf7f | 26 | void GolfEngine::update_ball(Gamepad &pad, int frame_rate) |
ellisbhastroud | 5:0b31909caf7f | 27 | { |
ellisbhastroud | 5:0b31909caf7f | 28 | |
ellisbhastroud | 5:0b31909caf7f | 29 | _ball.shoot_ball(pad); |
ellisbhastroud | 5:0b31909caf7f | 30 | _ball.check_wall_bounce(); |
ellisbhastroud | 5:0b31909caf7f | 31 | _ball.move_ball(frame_rate); |
ellisbhastroud | 5:0b31909caf7f | 32 | _ball.check_wall_bounce(); |
ellisbhastroud | 5:0b31909caf7f | 33 | } |
ellisbhastroud | 5:0b31909caf7f | 34 | |
ellisbhastroud | 5:0b31909caf7f | 35 | void GolfEngine::drawCourseWalls(N5110 &lcd) |
ellisbhastroud | 5:0b31909caf7f | 36 | { |
ellisbhastroud | 5:0b31909caf7f | 37 | for(int i = 0; i > 5; i++) { |
ellisbhastroud | 5:0b31909caf7f | 38 | 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 |
ellisbhastroud | 5:0b31909caf7f | 39 | } |
ellisbhastroud | 5:0b31909caf7f | 40 | } |
ellisbhastroud | 5:0b31909caf7f | 41 |