publish my project

Dependencies:   mbed

Revision:
0:9e95a5ef2659
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Attacker/Attacker.cpp	Mon Apr 27 06:14:34 2020 +0000
@@ -0,0 +1,191 @@
+#include "Attacker.h"
+Attacker::Attacker()
+{
+
+}
+Attacker::~Attacker()
+{
+
+}
+
+void Attacker::init1(int size,int speed)
+{
+    _size = size;
+
+    _x = 30;                       //attacker1  x-coordinate 
+    _y = 11;                      //            y-coordinate
+
+    srand(time(NULL));
+    int direction = rand() % 2;     // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = speed;
+        _velocity.y = speed;
+    } else {
+        _velocity.x = speed;
+        _velocity.y = speed+1;
+    }
+}
+
+void Attacker::init2(int size,int speed)
+{
+    _size = size;
+
+    _x = 54;              //attacker2  x-coordinate 
+    _y = 10;             //            y-coordinate
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = -speed+1;
+        _velocity.y = speed;
+    } else {
+        _velocity.x = -speed;
+        _velocity.y = speed;
+    }
+}
+void Attacker::init3(int size,int speed)
+{
+    _size = size;
+
+    _x = 10;                            //attacker3  x-coordinate 
+    _y = 17;                             //          y-coordinate
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = speed;
+        _velocity.y = speed;
+    } else {
+        _velocity.x = speed+1;
+        _velocity.y = speed;
+    }
+}
+void Attacker::init4(int size,int speed)
+{
+    _size = size;
+
+    _x = 10;       
+    _y = 31;
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = speed+1;
+        _velocity.y = -speed;
+    } else {
+        _velocity.x = speed;
+        _velocity.y = -speed;
+    }
+}
+void Attacker::init5(int size,int speed)
+{
+    _size = size;
+
+    _x = 30;
+    _y = 36;
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = speed+1;
+        _velocity.y = -speed;
+    } else {
+        _velocity.x = speed;
+        _velocity.y = -speed;
+    }
+}
+void Attacker::init6(int size,int speed)
+{
+    _size = size;
+
+    _x = 54;
+    _y = 36;
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = -speed-1;
+        _velocity.y = -speed;
+    } else {
+        _velocity.x = -speed;
+        _velocity.y = -speed;
+    }
+}
+void Attacker::init7(int size,int speed)
+{
+    _size = size;
+
+    _x = 71;
+    _y = 31;
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = -speed-2;
+        _velocity.y = -speed;
+    } else {
+        _velocity.x = -speed;
+        _velocity.y = -speed;
+    }
+}
+void Attacker::init8(int size,int speed)
+{
+    _size = size;
+
+    _x = 71;
+    _y = 17;
+
+    srand(time(NULL));
+    int direction = rand() % 2; // randomise initial direction. 
+
+    if (direction == 0) {
+        _velocity.x = -speed;
+        _velocity.y = speed;
+    } else {
+        _velocity.x = -speed-1;
+        _velocity.y = speed;
+    }
+}
+
+void Attacker::draw(N5110 &lcd)
+{
+    lcd.drawRect(_x,_y,_size,_size,FILL_BLACK);
+}
+
+void Attacker::update()
+{
+    _x += _velocity.x;
+    _y += _velocity.y;
+    /////////////////////////////////
+}
+
+void Attacker::set_velocity(Vector2D v)
+{
+    _velocity.x = v.x;
+    _velocity.y = v.y;
+}
+
+Vector2D Attacker::get_velocity()
+{
+    Vector2D v = {_velocity.x,_velocity.y};
+    return v;
+}
+
+Vector2D Attacker::get_pos()
+{
+    Vector2D p = {_x,_y};
+    return p;
+}
+
+void Attacker::set_pos(Vector2D p)
+{
+    _x = p.x;
+    _y = p.y;
+}