Ball drop game with menus and highscore tracking developed for ELEC2645 at the University of Leeds.

Dependencies:   N5110 mbed PowerControl

Game developed for ELEC 2645.

Extremely detailed report outlining all aspects of project found below. /media/uploads/AppleJuice/projectreport.pdf

Files at this revision

API Documentation at this revision

Comitter:
AppleJuice
Date:
Tue May 05 13:20:23 2015 +0000
Parent:
16:9d676eb9d8d1
Child:
18:0e8b1cc24706
Commit message:
Working version. Going to introduce ball and platform class

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue May 05 11:57:46 2015 +0000
+++ b/main.cpp	Tue May 05 13:20:23 2015 +0000
@@ -10,46 +10,41 @@
 
 int main()
 {
-    lcd.Initialize();
+    lcd.Initialize();       
 
     lcd.displayStartScreen();
-    while(!isRight()) {}    //wait until right button pressed
+    while(!isRight()) {}       //wait until right button pressed
 
-    wait(0.5);          //just to ignore layover from first button.
+    wait(0.5);          //just to ignore layover from first button press.
     lcd.displayInstructionScreen();
     while(!isRight()) {}    //wait until right button pressed.
 
     lcd.displayCountdown();
     lcd.clear();
 
-    leds = 1;
-
     bool refresh = false;
 
     lcd.drawAllPlatforms();
     lcd.drawBall();
     lcd.refresh();
 
-    gameClock.attach(&clockCounter,0.003);
+    gameClock.attach(&clockCounter,0.003);  //attach the master clock! 
 
     //MAIN GAME LOOP
     //multiple runs on a single loop. stop with a bool
 
     char buffer[10];
     while(true) {
-        if (isFirstCheck) {
-            if(clockCount %(gameSpeed) == 0) {
-                
-                if (gameLevel > 60)
-                    advancePlatforms(2);
-                else
-                    advancePlatforms(1);
+        if (isFirstCheck) { //if first time checking this clock cycle.
+            if(clockCount %(gameSpeed) == 0) {  
+                //advance platforms
+                advancePlatforms(1);
                 refresh = true;
             }
 
             if(clockCount%10 == 0) {
-                //check if moving left will move you into platform.
-                if (isLeft() && isBallDirClear(1)) {
+                //ball movement
+                if (isLeft() && isBallDirClear(1)) {    //if josystick left and direction is clear
                     lcd.eraseBall();
                     lcd.setBallPos(lcd.getBallX()+2,lcd.getBallY());
                     refresh = true;
@@ -60,7 +55,8 @@
                     refresh = true;
                 }
                 
-                if(isBallFalling(lcd.getBallY())) {
+                //if the ball is in free space, animate it falling!
+                if(isBallFalling(lcd.getBallY())) { 
                     lcd.eraseBall();
                     lcd.setBallPos(lcd.getBallX(),lcd.getBallY() + 1);
                     refresh = true;