Library that draws a basket on a Nokia N5110 LCD display and allows it to be moved left/right on the display using buttons or a joystick.

Dependents:   Game_Controller_Project

Revision:
0:7e132fca6044
Child:
1:5e564d218751
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Basket.cpp	Tue Mar 14 10:00:01 2017 +0000
@@ -0,0 +1,66 @@
+#include "Basket.h"
+
+Basket::Basket()
+{
+    
+}
+
+Basket::~Basket()
+{
+    
+}
+
+void Basket::Basket_init(int y, int width)
+{
+    basket_y = y;
+    basket_x = WIDTH/2 - width/2;
+    basket_width = width;
+    basket_speed = 1;
+    basket_score = 0;
+}
+
+void Basket::Basket_draw(N5110 &lcd)
+{
+    lcd.drawRect(basket_x,basket_y, 1, 2, 0);
+    lcd.drawRect(basket_x + 1, basket_y + 2,1,2,0);
+    lcd.setPixel(basket_x + 2, basket_y + 4);
+    lcd.drawRect(basket_x + 2, basket_y + 5, basket_width - 4, 1, 0);
+    lcd.setPixel(basket_x + 9, basket_y + 4);
+    lcd.drawRect(basket_x + 10, basket_y + 2, 1, 2, 0);
+    lcd.drawRect(basket_x + 11, basket_y, 1, 2, 0);
+}
+
+void Basket::Basket_move(Direction d, float mag, Gamepad &pad)
+{
+    basket_speed = int(mag*5.0f);
+    
+    if (d == E || pad.check_event(Gamepad::R_PRESSED)) {
+        basket_x += basket_speed;
+    } else if (d == W || pad.check_event(Gamepad::L_PRESSED)) {
+        basket_x -= basket_speed;
+    }
+    
+    if (basket_x < 1) {
+        basket_x = 1;
+    }
+    if (basket_x > WIDTH - basket_width - 1) {
+        basket_x = WIDTH - basket_width - 1;
+    }
+}
+
+void Basket::Basket_score()
+{
+    basket_score++;
+}
+
+int Basket::get_Basket_score()
+{
+    return basket_score;
+}
+/*
+Vector2D Basket::Basket_position()
+{
+    Vector2D pos = (basket_x,basket_y);
+    return pos;
+}
+*/
\ No newline at end of file