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/Enemy.cpp
- Revision:
- 9:62fe47a1374f
- Parent:
- 8:0c6d6ed55851
- Child:
- 10:71ced616a64f
diff -r 0c6d6ed55851 -r 62fe47a1374f Enemy/Enemy.cpp
--- a/Enemy/Enemy.cpp Fri May 22 16:54:10 2020 +0000
+++ b/Enemy/Enemy.cpp Sat May 23 13:26:19 2020 +0000
@@ -4,7 +4,7 @@
// nothing doing in the constructor and destructor
Enemy::Enemy(int seed)
{
-
+ _dead = false;
srand(seed);
four = (rand()%4)+1;
//pce.printf("%d",four);
@@ -42,6 +42,7 @@
void Enemy::update(int player_x, int player_y)
{
+ if(_dead == false){
if(_x<player_x){
_x++;
}
@@ -55,6 +56,7 @@
else if (_y > player_y){
_y--;
}
+ }
}
int Enemy::get_x()
{
@@ -67,9 +69,11 @@
}
void Enemy::dead(){
+ _dead = true;
_x = 2147483647;
}
void Enemy::reset(int seed){
+ _dead = false;
srand(seed);
four = (rand()%4)+1;
//pce.printf("%d",four);