runner

Dependencies:   mbed

Revision:
3:59e67155e2dd
Child:
4:7fca66882a00
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Obstacle/Obstacle.cpp	Thu May 09 05:01:02 2019 +0000
@@ -0,0 +1,42 @@
+#include "Obstacle.h"
+
+// nothing doing in the constructor and destructor
+Obstacle::Obstacle()
+{
+
+}
+
+Obstacle::~Obstacle()
+{
+
+}
+
+void Obstacle::init(int y,int height,int width)
+{
+    _x = WIDTH - 5;  // x value on screen is fixed
+    _y = y;
+    _height = height;
+    _width = width;
+
+}
+
+void Obstacle::draw(N5110 &lcd)
+{
+    lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
+}
+
+void Obstacle::update()
+{
+    _speed = 3;
+    _x -= _speed;
+    // check the x origin to ensure that the obstacle doesn't go beyond screen
+    if (_x < 0) {
+        _x = 1;
+    }
+}
+
+
+Vector2D Obstacle::get_pos() {
+    Vector2D p = {_x,_y};
+    return p;    
+}
\ No newline at end of file