ELEC2645 (2018/19) / Mbed 2 deprecated 2645_Project_SiutingWong201186503

Dependencies:   mbed

Revision:
0:fd8eda608206
Child:
1:f09ff0ed98fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Wall/Wall.cpp	Wed May 08 18:50:21 2019 +0000
@@ -0,0 +1,48 @@
+#include "Wall.h"
+
+Wall::Wall()
+{
+
+}
+
+Wall::~Wall()
+{
+
+}
+
+void Wall::init(int x,int gap,int width,int speed) {
+    
+    _x = x;  // x value on screen is fixed
+    int uncertainty = rand() % 39;
+    _height = uncertainty;  // y depends on height of screen and height of paddle
+    _gap = gap;
+    _width = width;
+    _speed = speed;
+}
+
+void Wall::draw1(N5110 &lcd) {
+    
+    // draw wall in screen buffer. 
+    lcd.drawRect(_x,0,_width,_height,FILL_BLACK);
+}
+
+void Wall::draw2(N5110 &lcd) {
+    lcd.drawRect(_x,(_gap + _height),_width,(HEIGHT - (_gap + _height)),FILL_BLACK);
+}
+
+void Wall::update() {
+     // scale is arbitrary, could be changed in the future
+    _x -= _speed;
+}
+
+void Wall::reset() {
+    
+    _x = 99;
+    int uncertainty = rand() % 39;
+    _y = 8 + uncertainty;
+}
+
+
+Vector2D Wall::get_height() {
+    return _height;
+}
\ No newline at end of file