Some random attempts at programming the retro console

Dependencies:   LCD_ST7735 mbed

Fork of RETRO_Pong_Mod by G. Andrew Duthie

Revision:
10:ba2dea5fffd1
Parent:
9:5c4a3e89a713
diff -r 5c4a3e89a713 -r ba2dea5fffd1 Game.cpp
--- a/Game.cpp	Sat Feb 28 14:46:09 2015 +0000
+++ b/Game.cpp	Sat Feb 28 17:39:08 2015 +0000
@@ -36,7 +36,6 @@
     
     this->lastUp = false;
     this->lastDown = false;
-    this->mode = true;
     this->cCol = 0;
     
     this->i2c.frequency(400);
@@ -75,51 +74,12 @@
     y = this->convert(buffer + 2);
 }
 
-void Game::getXYZ(double& x, double& y, double& z) {
-    char buffer[6];
-    this->readRegisters(0x01, buffer, 4);
-    x = this->convert(buffer);
-    y = this->convert(buffer + 2);
-    z = this->convert(buffer + 4);
-
-}
-
 void Game::printDouble(double value, int x, int y) {
     char buffer[10];
     int len = sprintf(buffer, "%.1f", value);
     this->disp.drawString(font_ibm, x, y, buffer);
 }
 
-void Game::drawAxes() {
-    for (int i = 0; i < 3; i++) {
-        this->disp.drawLine(0, i * (Game::GRAPH_HEIGHT + Game::GRAPH_SPACING), 0, i * (Game::GRAPH_HEIGHT + Game::GRAPH_SPACING) + Game::GRAPH_HEIGHT, Color565::White);
-        this->disp.drawLine(0, i * (Game::GRAPH_HEIGHT + Game::GRAPH_SPACING) + Game::GRAPH_HEIGHT / 2, disp.getWidth(), i * (Game::GRAPH_HEIGHT + Game::GRAPH_SPACING) + Game::GRAPH_HEIGHT / 2, Color565::White);
-    }
-}
-
-void Game::drawPoint(int axis, double value) {
-    if (value < -1.0)
-        value = -1.0;
-
-    if (value > 1.0)
-        value = 1.0;
-
-    value += 1.0;
-    value /= 2.0;
-    value = 1.0 - value;
-    value *= Game::GRAPH_HEIGHT;
-
-    this->disp.setPixel(this->graphX, axis * (Game::GRAPH_HEIGHT + Game::GRAPH_SPACING) + (int)value, this->colors[axis]);
-}
-
-void Game::checkGraphReset() {
-    if (this->graphX > disp.getWidth()) {
-        this->graphX = 0;
-        this->disp.clearScreen();
-        this->drawAxes();
-    }
-}
-
 void Game::initialize() {
     this->disp.setOrientation(LCD_ST7735::Rotate270, false);    
     this->disp.clearScreen();
@@ -154,47 +114,20 @@
     int tcount = 0;
     this->checkButtons();
     
-    if (this->mode) {
-        if ((tcount++ % 10) == 0) {
-          this->readAccel();
-        };
-        this->updateBall();
-        this->checkCollision();
-        this->clearBall();
-        this->drawBall();
-        // this->checkPwm();
-        //this->checkLives(); 
-    }
-    else {    
-        double x, y, z;
-        
-        this->getXYZ(x, y, z);
-        
-        this->checkGraphReset();
-        this->drawPoint(0, x);
-        this->drawPoint(1, y);
-        this->drawPoint(2, z);
-        this->graphX++;
-    } 
+    if ((tcount++ % 10) == 0) {
+        this->readAccel();
+    };
+    this->clearBall();
+    this->updateBall();
+    this->checkCollision();
+    this->drawBall();
+    //this->checkPwm();
+    //this->checkLives(); 
 }
 
 void Game::checkButtons() {
     if (!this->square.read()) {
-        //this->muted = !this->muted;
-        this->mode = !this->mode;
-        
-        this->disp.clearScreen();
-        
-        if (!this->mode) {
-            this->graphX = 0;
-            
-            this->drawAxes();
-        }
-        
-        //this->led1.write(this->muted);
-        //this->led2.write(!this->muted);
-        //this->led1.write(this->mode);
-        //this->led2.write(!this->mode);
+        this->muted = !this->muted;
     }  
     
     bool xDir = this->ballSpeedX > 0.0;
@@ -246,7 +179,7 @@
                         ballY - BALL_RADIUS,
                         ballX + BALL_RADIUS,
                         ballY + BALL_RADIUS,
-                        Color565::Gray);
+                        Color565::Black);
 }
 
 void Game::drawBall() {
@@ -284,10 +217,10 @@
         this->bounce();
     }
     // Sanity
-    this->printDouble(this->ballSpeedX, 1, 0);
-    this->printDouble(this->ballSpeedY, 1, 8);
-    this->printDouble(this->ballAccelX, 120, 0);
-    this->printDouble(this->ballAccelY, 120, 8);
+    //this->printDouble(this->ballSpeedX, 1, 0);
+    //this->printDouble(this->ballSpeedY, 1, 8);
+    //this->printDouble(this->ballAccelX, 120, 0);
+    //this->printDouble(this->ballAccelY, 120, 8);
 }
 
 void Game::bounce() {
@@ -345,7 +278,6 @@
 */
 
 }
-
 void Game::checkPwm() {
     if (this->pwmTicksLeft == 0) {
          this->pwm.write(0.0);