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
Diff: RosenEngine/RosenEngine.cpp
- Revision:
- 18:2cc6898de6b2
- Parent:
- 17:e65a9f981834
- Child:
- 19:3316dba9787e
diff -r e65a9f981834 -r 2cc6898de6b2 RosenEngine/RosenEngine.cpp --- a/RosenEngine/RosenEngine.cpp Sat Apr 13 08:28:01 2019 +0000 +++ b/RosenEngine/RosenEngine.cpp Sat Apr 13 14:26:05 2019 +0000 @@ -20,6 +20,7 @@ // place seeker above the ship _enemy.init(ship_xpos, 0); _menu.init(16); + _health.init(_xcursor); } @@ -34,6 +35,8 @@ void RosenEngine::draw(N5110 &lcd, Gamepad &pad) { + _health.draw_health(lcd); + _health.draw_shields(lcd); _enemy.draw_seeker(lcd); if(_xcursor == 0) { _ship.set_dimensions(9,6); @@ -74,10 +77,10 @@ _weapons.update(); } // _menu.update(_d); + check_enemy_ship_collision(); } void RosenEngine::get_pos() { - Vector2D ship_pos = _ship.get_pos(); ship_xpos = ship_pos.x; ship_ypos = ship_pos.y; @@ -105,3 +108,12 @@ _menu.update(_d); _menu.disp_ships(lcd); } +void RosenEngine::check_enemy_ship_collision() +{ + Vector2D ship_pos = _ship.get_pos(); + Vector2D s_pos = _enemy.get_seekerpos(); + if(ship_pos.x == s_pos.x && ship_pos.y == s_pos.y) { + _health.update(1); + _enemy.reset_seeker(); + } +} \ No newline at end of file