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:
- 8:0c6d6ed55851
- Parent:
- 6:546eba371942
- Child:
- 9:62fe47a1374f
diff -r 0434857199cf -r 0c6d6ed55851 Enemy/Enemy.cpp
--- a/Enemy/Enemy.cpp Fri May 22 15:46:14 2020 +0000
+++ b/Enemy/Enemy.cpp Fri May 22 16:54:10 2020 +0000
@@ -6,9 +6,8 @@
{
srand(seed);
- int four;
four = (rand()%4)+1;
- pce.printf("%d",four);
+ //pce.printf("%d",four);
if(four == 1){
_x = 0;
_y = rand()%48;
@@ -55,7 +54,7 @@
}
else if (_y > player_y){
_y--;
- }
+ }
}
int Enemy::get_x()
{
@@ -67,3 +66,27 @@
return _y;
}
+void Enemy::dead(){
+ _x = 2147483647;
+}
+void Enemy::reset(int seed){
+ srand(seed);
+ four = (rand()%4)+1;
+ //pce.printf("%d",four);
+ if(four == 1){
+ _x = 0;
+ _y = rand()%48;
+ }
+ else if(four == 2){
+ _x = 84;
+ _y = rand()%48;
+ }
+ else if(four == 3){
+ _y = 0;
+ _x = rand()%84;
+ }
+ else if(four == 4){
+ _y = 48;
+ _x = rand()%84;
+ }
+}