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:
9:05fd30d491f1
Parent:
8:48c5adc809e1
Child:
10:2e441532206e
diff -r 48c5adc809e1 -r 05fd30d491f1 Basket.cpp
--- a/Basket.cpp	Tue Apr 18 14:27:06 2017 +0000
+++ b/Basket.cpp	Sat Apr 22 12:21:58 2017 +0000
@@ -9,7 +9,7 @@
 {
     
 }
-
+//INITILISATION FUNCTION//
 void Basket::init(int y, int width)
 {
     y_ref = y;
@@ -18,17 +18,7 @@
     score = 0;
 }
 
-void Basket::draw(N5110 &lcd)
-{
-    lcd.drawRect(x_ref,y_ref, 1, 2, 0);
-    lcd.drawRect(x_ref + 1, y_ref + 2,1,2,0);
-    lcd.setPixel(x_ref + 2, y_ref + 4);
-    lcd.drawRect(x_ref + 2, y_ref + 5, basket_width - 4, 1, 0);
-    lcd.setPixel(x_ref + 9, y_ref + 4);
-    lcd.drawRect(x_ref + 10, y_ref + 2, 1, 2, 0);
-    lcd.drawRect(x_ref + 11, y_ref, 1, 2, 0);
-}
-
+//UPDATE FUNCTIONS//
 void Basket::move_stick(Direction d, float mag)
 {
     stick_speed = int(mag*6.0f);
@@ -63,6 +53,7 @@
     }
 }
 
+//SCORE FUNCTIONS//
 void Basket::add_score_1()
 {
     score++;
@@ -88,6 +79,18 @@
     return score;
 }
 
+//DISPLAY FUNCTIONS//
+void Basket::draw(N5110 &lcd)
+{
+    lcd.drawRect(x_ref,y_ref, 1, 2, 0);
+    lcd.drawRect(x_ref + 1, y_ref + 2,1,2,0);
+    lcd.setPixel(x_ref + 2, y_ref + 4);
+    lcd.drawRect(x_ref + 2, y_ref + 5, basket_width - 4, 1, 0);
+    lcd.setPixel(x_ref + 9, y_ref + 4);
+    lcd.drawRect(x_ref + 10, y_ref + 2, 1, 2, 0);
+    lcd.drawRect(x_ref + 11, y_ref, 1, 2, 0);
+}
+
 int Basket::get_x()
 {
     return x_ref;