Game designed for project

Dependencies:   mbed Gamepad2

Revision:
2:e67ca889c81b
diff -r d1f0f22ecfc4 -r e67ca889c81b MyClasses/PaddleControl.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClasses/PaddleControl.cpp	Tue May 19 09:51:13 2020 +0000
@@ -0,0 +1,38 @@
+
+#include "PaddleControl.h"
+
+
+void Paddle::init(int y,int length,int height)
+{
+    _y = y;  // x value on screen is fixed
+    _x = WIDTH/2 - length/2;  // y depends on height of screen and height of paddle
+    _height = height;
+    _length = length;
+    _speed = 1;  // default speed
+}
+
+void Paddle::print_lcd(N5110 &lcd)
+{
+    lcd.drawRect(_x,_y,_width,_height,FILL_BLACK);
+}
+
+void Paddle::update(char direction)
+{
+    if (direction == 'R') {
+        _x-=_speed;
+    } else if (direction == 'L') {
+        _x+=_speed;
+    }
+
+    if (_x < 1) {
+        _x = 1;
+    }
+    if (_x > WIDTH - _length - 1) {
+        _x = WIDTH - _length - 1;
+    }
+}
+
+Vector2D Paddle::get_pos() {
+    Vector2D p = {_x,_y};
+    return p;    
+}
\ No newline at end of file