ECE 4180 Final

Dependencies:   mbed wave_player mbed-rtos C12832_lcd 4DGL-uLCD-SE LCD_fonts SDFileSystem

Revision:
19:d65f9fb1023b
Child:
20:7d56cdcbc9a5
diff -r 548fdf1a9736 -r d65f9fb1023b Lane.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lane.cpp	Fri Dec 06 15:46:16 2019 +0000
@@ -0,0 +1,45 @@
+#include "Lane.hpp"
+#include "globals.h"
+
+Lane::Lane(int x, int y) {
+    xpos = x;
+    ypos = y;
+    empty = false;
+}
+
+void Lane::add() {
+    ++bubblesDrawn;
+    pops.push_back(Bubble(xpos, ypos));
+}
+
+void Lane::draw() {
+    for (pops_ptr = pops.begin(); pops_ptr < pops.end(); pops_ptr++) {
+        (*pops_ptr).draw();
+    }
+}
+
+void Lane::moveDown() {
+    // move each bubble
+    //if they're past a certain horizontal limit, remove them from the dynamic array
+    if ((pops.begin())->getYpos() >= 110+20) {
+        // black out the bubble and remove it from the lane's vector
+        (pops.begin())->clear();
+        pops.erase(pops.begin());
+    }
+    
+    for (pops_ptr = pops.begin(); pops_ptr < pops.end(); pops_ptr++) {
+        (*pops_ptr).moveDown();
+    }
+}
+
+bool Lane::isEmpty() {
+    return pops.empty();
+}
+
+void Lane::checkHit() {
+    if ((pops.begin())->getYpos() <= 110+20 && (pops.begin())->getYpos() >= 110-20) {
+        // black out the bubble and remove it from the lane's vector
+        (pops.begin())->clear();
+        pops.erase(pops.begin());
+    }
+}
\ No newline at end of file