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
Revision 67:4299b64ad5fc, committed 2019-04-27
- Comitter:
- fy14lkaa
- Date:
- Sat Apr 27 18:56:09 2019 +0000
- Parent:
- 66:0123bd3dcbc6
- Child:
- 68:175190a03cbd
- Commit message:
- added if statement to check if the bullet hits the top of the Alien.
Changed in this revision
| SpaceInvadersEngine/SpaceInvadersEngine.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SpaceInvadersEngine/SpaceInvadersEngine.cpp Sat Apr 27 18:42:35 2019 +0000
+++ b/SpaceInvadersEngine/SpaceInvadersEngine.cpp Sat Apr 27 18:56:09 2019 +0000
@@ -66,6 +66,14 @@
Vector2D bullet_velocity = _bullet.get_velocity();
//check if the bullet hit the top of the alien
+ // check if the bullet hits top of the Alien
+ if (bullet_pos.y <= 1) { // 1 due to 1 pixel boundary
+ bullet_pos.y = 1; // bounce off ceiling without going off screen
+ bullet_velocity.y = -bullet_velocity.y;
+ // audio feedback
+ pad.tone(750.0,0.1);
+ }
+
}