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/Enemy1.cpp
- Revision:
- 18:ba4159ab4da7
- Parent:
- 16:37d98c281eb3
- Child:
- 21:7d4827af00d6
--- a/Enemy/Enemy1.cpp Wed May 08 13:03:24 2019 +0000
+++ b/Enemy/Enemy1.cpp Wed May 08 15:01:45 2019 +0000
@@ -28,20 +28,12 @@
void Enemy1::movement(N5110 &lcd){
accel = 1;
- for (int i = 0; i < 60; i++) {
- if (y_enem == 17 && x_enem < 50){
- x_enem += accel;
- }
- if (y_enem < 24 && x_enem == 50){
- y_enem += accel;
- }
- if (y_enem == 24 && x_enem > 27){
- x_enem -= accel;
- }
- if (y_enem > 17 && x_enem == 27){
- y_enem -= accel;
- }
- }
+ _incrementer_enem1++;
+ if ( _incrementer_enem1 == 62 ) { _incrementer_enem1 = 0; }
+ if ( _incrementer_enem1 >= 0 && _incrementer_enem1 <= 23) { x_enem++; }
+ else if ( _incrementer_enem1 >= 24 && _incrementer_enem1 <= 30) { y_enem++; }
+ else if ( _incrementer_enem1 >= 31 && _incrementer_enem1 <= 54) { x_enem--; }
+ else if ( _incrementer_enem1 >= 55 && _incrementer_enem1 <= 61) { y_enem--; }
}
bool Enemy1::northCollision(int x, int y, N5110 &lcd){