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: Enemy/Enemy2.cpp
- Revision:
- 16:37d98c281eb3
- Parent:
- 14:d0650d0de063
- Child:
- 21:7d4827af00d6
--- a/Enemy/Enemy2.cpp Mon May 06 18:39:40 2019 +0000 +++ b/Enemy/Enemy2.cpp Wed May 08 09:05:27 2019 +0000 @@ -23,19 +23,15 @@ } void Enemy2::drawSprite(N5110 &lcd){ - lcd.drawSprite(x_enem,y_enem,7,7,(int *)enemy_B); + lcd.drawSprite(x_enem, y_enem,7,7,(int *)enemy_B); } void Enemy2::movement(N5110 &lcd){ accel = 1; - for (int i = 0; i < 14; i++) { - if (20 < y_enem < 32){ - y_enem += accel; - } - if (y_enem == 32){ - y_enem -= accel; - } - } + _incrementer_enem2++; + if ( _incrementer_enem2 == 28 ) { _incrementer_enem2 = 0; } + if ( _incrementer_enem2 >= 0 && _incrementer_enem2 <= 13) { y_enem++; } + else if ( _incrementer_enem2 >= 14 && _incrementer_enem2 <= 27) { y_enem--; } } bool Enemy2::northCollision(int x, int y, N5110 &lcd){ @@ -56,4 +52,19 @@ } } return false; +} + +bool Enemy2::collidePlayer(int x, int y, Gamepad &pad) { + + for (int ix = 0; ix < 7; ix++) { + for (int iy = 0; iy < 7; iy++) { + if ( x + ix == x_enem + 3 && + y + iy == y_enem + 3 ) { + pad.tone(400,0.5); + return true; + + } + } + } + return false; } \ No newline at end of file