Some random attempts at programming the retro console

Dependencies:   LCD_ST7735 mbed

Fork of RETRO_Pong_Mod by G. Andrew Duthie

Revision:
8:c63981a45c95
Parent:
7:c0f12f624832
Child:
9:5c4a3e89a713
diff -r c0f12f624832 -r c63981a45c95 Game.cpp
--- a/Game.cpp	Fri Feb 27 20:21:32 2015 +0000
+++ b/Game.cpp	Sat Feb 28 00:04:52 2015 +0000
@@ -31,7 +31,8 @@
                 pwm(P0_18),
                 ain(P0_15),
                 i2c(P0_5, P0_4),
-                disp(P0_19, P0_20, P0_7, P0_21, P0_22, P1_15, P0_2, LCD_ST7735::RGB) {
+                disp(P0_19, P0_20, P0_7, P0_21, P0_22, P1_15, P0_2, LCD_ST7735::RGB),
+                music(P0_18) {
     srand(this->ain.read_u16());
     
     this->lastUp = false;
@@ -44,7 +45,6 @@
     this->colors[0] = Color565::Red;
     this->colors[1] = Color565::Green;
     this->colors[2] = Color565::Blue;
-    
     this->initialize();
 }
 
@@ -122,15 +122,22 @@
     }
 }
 
-void Game::initialize() {    
+void playSong() {
+    MusicEngine music(P0_18);
+    music.play("t160o3l4V12@1ed8ce8gg8er8aa8>c<a8g2raa8ga8>cc8d<r8ee8de8c2rdd8dd8dd8dr8ed8ef8g2raa8ga8>cc8<ar8>dc8de8d2<r>ee8dc8<ab8>cc8<gg8ea8g2r>cc8<ge8cd8ea8gg8de8");
+}
+
+void Game::initialize() {
+    this->music.setCompletionCallback(&playSong);
+    playSong();
     this->initializeBall();
     this->pwmTicksLeft = 0;
     this->lives = 4;
     this->score = 0;
     this->muted = false;
     
-    this->pwm.period(1);
-    this->pwm.write(0.00);
+    //this->pwm.period(1);
+    //this->pwm.write(0.00);
     this->disp.setOrientation(LCD_ST7735::Rotate270, false);    
     this->disp.clearScreen();
 }
@@ -163,9 +170,9 @@
         if ((tcount++ % 10) == 0) {
           this->readAccel();
         };
-        this->clearBall();
         this->updateBall();
         this->checkCollision();
+        this->clearBall();
         this->drawBall();
         // this->checkPwm();
         //this->checkLives(); 
@@ -198,8 +205,8 @@
         
         //this->led1.write(this->muted);
         //this->led2.write(!this->muted);
-        this->led1.write(this->mode);
-        this->led2.write(!this->mode);
+        //this->led1.write(this->mode);
+        //this->led2.write(!this->mode);
     }  
     
     bool xDir = this->ballSpeedX > 0;
@@ -253,7 +260,7 @@
                         ballY - BALL_RADIUS,
                         ballX + BALL_RADIUS,
                         ballY + BALL_RADIUS,
-                        Color565::Black);
+                        Color565::Gray);
 }
 
 void Game::drawBall() {