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:
 - 5:51fd6635141f
 - Child:
 - 6:546eba371942
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Enemy/Enemy.cpp	Wed May 20 21:39:09 2020 +0000
@@ -0,0 +1,50 @@
+#include "Enemy.h"
+#include <Bitmap.h>
+// nothing doing in the constructor and destructor
+Enemy::Enemy()
+{
+
+}
+
+Enemy::~Enemy()
+{
+
+}
+
+void Enemy::init()
+{
+    _x = 84;
+    _y = 48;
+}
+
+void Enemy::draw(N5110 &lcd)
+{
+    lcd.drawRect(_x,_y,3,3,FILL_TRANSPARENT);
+}
+
+void Enemy::update(int player_x, int player_y)
+{
+    if(_x<player_x){
+        _x++;
+        }
+    else if(_x > player_x){
+        _x--;
+        } 
+        
+    if(_y < player_y){
+        _y++;
+        }
+    else if (_y > player_y){
+        _y--;
+        }     
+}
+int Enemy::get_x()
+{   
+    return _x;
+    
+}
+int Enemy::get_y()
+{   
+    return _y;
+    
+}