ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

Dependencies:   mbed

Revision:
6:546eba371942
Parent:
5:51fd6635141f
Child:
8:0c6d6ed55851
--- a/Enemy/Enemy.cpp	Wed May 20 21:39:09 2020 +0000
+++ b/Enemy/Enemy.cpp	Fri May 22 14:58:55 2020 +0000
@@ -1,9 +1,30 @@
 #include "Enemy.h"
 #include <Bitmap.h>
+Serial pce(USBTX, USBRX);
 // nothing doing in the constructor and destructor
-Enemy::Enemy()
+Enemy::Enemy(int seed)
 {
 
+    srand(seed);
+    int four;
+    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;
+        }
 }
 
 Enemy::~Enemy()
@@ -13,8 +34,6 @@
 
 void Enemy::init()
 {
-    _x = 84;
-    _y = 48;
 }
 
 void Enemy::draw(N5110 &lcd)