Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Wall/Wall.cpp
- 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