deemo1

Dependencies:   mbed

Revision:
1:8c48fb8ca5e0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Swarm/Swarm.cpp	Mon May 11 06:50:18 2020 +0000
@@ -0,0 +1,78 @@
+#include "Swarm.h"
+
+Swarm::Swarm()
+{
+    
+}
+
+Swarm::~Swarm()
+{
+    
+}
+
+int Swarmm[6][6] = {
+    {0,0,1,1,0,0},
+    {0,0,1,1,0,0},
+    {1,1,1,1,1,1},
+    {1,1,1,1,1,1},
+    {0,0,1,1,0,0},
+    {0,0,1,1,0,0},
+};
+
+void Swarm::init(int height, int width, int speed)
+{
+     _height = height;
+     _width = width;
+     _x = rand() % 64;
+     _y = 2;
+     
+     srand(time(NULL));
+     
+     _velocity.x = 0;
+     _velocity.y = speed;
+}    
+     
+void Swarm::draw(N5110 &lcd)     
+{
+     lcd.drawSprite(_x,_y,_height,_width,(int*)Swarmm);  
+}
+
+void Swarm::update()
+{
+    _x += _velocity.x;
+    _y += _velocity.y;
+}   
+     
+void Swarm::set_velocity(Vector2D v)
+{
+    _velocity.x = v.x;
+    _velocity.y = v.y;
+}
+
+Vector2D Swarm::get_velocity()
+{
+    Vector2D v = {_velocity.x,_velocity.y};
+    return v;
+}
+ 
+Vector2D Swarm::get_pos()
+{
+    Vector2D p = {_x,_y};
+    return p;
+}
+ 
+void Swarm::set_pos(Vector2D p)
+{
+    _x = p.x;
+    _y = p.y;
+}
+
+
+
+
+
+
+
+
+
+ 
\ No newline at end of file