ELEC2645 (2019/20)
/
ELEC2645_Project_el18jb
test 1 doc
Diff: Engine/Engine.cpp
- Revision:
- 6:00d20886e4f8
- Parent:
- 5:928c2eee4109
- Child:
- 7:530ca713d2b2
diff -r 928c2eee4109 -r 00d20886e4f8 Engine/Engine.cpp --- a/Engine/Engine.cpp Fri May 22 01:26:24 2020 +0000 +++ b/Engine/Engine.cpp Mon May 25 16:17:58 2020 +0000 @@ -2,23 +2,27 @@ Engine::Engine() { - } Engine::~Engine() { - } + +////////////////////// INIT //////////////////////////// void Engine::init() { //init coord _px = WIDTH / 2; - _py = HEIGHT / 2; - _plat.init(); + _py = 10; + + //init call _p.init(_px, _py); } + + +////////////////////// INPUT ////////////////////////// //reads direction and magnitude from the JOYSTICK to control the player void Engine::read_input(Gamepad &pad) { @@ -26,33 +30,54 @@ _mag = pad.get_mag(); } - -//draw both player and map +////////////////////// DRAW /////////////////////////// +//draw both player and map void Engine::draw(N5110 &lcd) { + // player _p.draw(lcd); - _plat.draw(lcd); - + drawMap(lcd); + } +////////////////////// UPDATE ////////////////////////// //provide the player file with necessary Joystick values void Engine::update(Gamepad &pad) { + _p.update(_d,_mag); +} - _p.update(_d,_mag); +/* + floorCollide(); + + if (_collision == true) { + + //debug + //printf("collison\n"); + } else { + + //debug + //printf("no collison\n"); + } //enemmyCollide(pad); } +*/ + +/* +////////////////////// FLOOR COLLISION ////////////////////////// +bool Engine::floorCollide() +{ + Vector2D player = _p.get_pos(); + _collision = false; + + if ( player.x +1 >= plat.x && player.x +1 <= plat.x + plat.width ) { + _collision = true; + } else { + _collision = false; + } + return _collision; +} -/* - -void PongEngine::check_paddle_collisions(Gamepad &pad) -{ -} - -void PongEngine::print_health(N5110 &lcd) -{ -} - */ \ No newline at end of file