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
- Committer:
- ellisbhastroud
- Date:
- 2019-04-18
- Revision:
- 8:d410856c6d04
- Parent:
- 7:5a19dd9fe8a4
- Child:
- 9:bc34f2243e43
File content as of revision 8:d410856c6d04:
#include "GolfEngine.h" // constructor GolfEngine::GolfEngine() { } //deconstructor GolfEngine::~GolfEngine() { } Course map_1[6] = {{LEFT,{9,26},{9,40}}, {BOTTOM,{9,40},{74,40}}, {RIGHT,{74,9},{74,40}}, {TOP,{56,9},{74,9}}, {LEFT,{56,9},{56,26}}, {TOP,{9,26},{56,26}}}; void GolfEngine::init() { _x_pos = 30; _y_pos = 30; _ball.init(_x_pos,_y_pos); } void GolfEngine::drawGame(N5110 &lcd, Gamepad &pad) { _ball.drawBall(lcd); _ball.drawPower(lcd, _mag); _ball.drawAim(lcd, _joy_coord, _angle); _ball.printShotCount(lcd); drawCourseWalls(lcd,map_1,6); } void GolfEngine::read_input(Gamepad &pad) { _joy_coord = pad.get_mapped_coord(); _mag = pad.get_mag(); _angle = pad.get_angle(); } void GolfEngine::update_ball(Gamepad &pad, int frame_rate) { _ball.shoot_ball(pad, _joy_coord); _ball.check_wall_bounce(map_1, 6); _ball.move_ball(frame_rate); _ball.check_wall_bounce(map_1, 6); } void GolfEngine::drawCourseWalls(N5110 &lcd, Course map[], int size) { for(int i = 0; i < size; i++){ lcd.drawLine(map[i].start.x,map[i].start.y,map[i].end.x,map[i].end.y,1); } } void GolfEngine::set_level(int level) { _level = level; } int GolfEngine::get_level() { return _level; }