ELEC2645 (2017/18) / Mbed 2 deprecated ll14zs

Dependencies:   mbed

Fork of ll14zs by Zeshaan Saeed

Revision:
3:1231a3961984
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Level/Level.cpp	Thu May 24 17:37:17 2018 +0000
@@ -0,0 +1,61 @@
+#include "Level.h"
+
+Level::Level()
+{
+    _height = 1; 
+    srand(time(NULL));
+    _width = rand()%70;
+    //printf("%d\n",levelwidth)
+    
+    _x = 1;
+    _y = 45;
+    
+    int direction = 0;
+    
+    if (direction == 0) {
+        _velocity.y = -(1);
+    }
+}
+
+Level::~Level()
+{
+    
+}
+
+void Level::draw(N5110 &lcd)
+{
+    lcd.drawRect(_x,_y,_width,_height,1);
+    lcd.drawRect((_width +10),_y,(70-_width),_height,1);
+}
+
+void Level::update()
+{
+    _x += _velocity.x;
+    _y += _velocity.y;
+}
+
+void Level::set_velocity(Vector2D v)
+{
+    _velocity.x = v.x;
+    _velocity.y = v.y;
+}
+
+Vector2D Level::get_velocity()
+{
+    Vector2D v = {_velocity.x,_velocity.y};
+    return v;
+}
+
+Vector2D Level::get_pos()
+{
+    Vector2D p - {_x,_y};
+    return p;
+}
+
+void Level::set_pos(Vector2D p)
+{
+    _x = p.x;
+    _y = p.y;
+    
+}
+    
\ No newline at end of file