Some random attempts at programming the retro console

Dependencies:   LCD_ST7735 mbed

Fork of RETRO_Pong_Mod by G. Andrew Duthie

Revision:
6:20788dfdb7b8
Parent:
5:8a26ad9d9ea1
Child:
7:c0f12f624832
--- a/Game.cpp	Wed Feb 25 23:28:49 2015 +0000
+++ b/Game.cpp	Thu Feb 26 20:29:02 2015 +0000
@@ -116,8 +116,8 @@
 void Game::initializeBall() {
     this->ballX = DisplayN18::WIDTH / 2 - Game::BALL_RADIUS;
     this->ballY = DisplayN18::HEIGHT / 4 - Game::BALL_RADIUS;
-    this->ballSpeedX = 3;
-    this->ballSpeedY = 5;
+    this->ballSpeedX = 0;
+    this->ballSpeedY = 0;
     this->ballAccelX = 0;
     this->ballAccelY = 0;
 }
@@ -125,22 +125,31 @@
 void Game::readAccel() {
     double x, y, z;
     this->getXYZ(x, y, z);
-    this->ballAccelX = floor(x);
-    this->ballAccelY = floor(y);
+    x = x * 8;
+    y = y * 8;
+    this->ballAccelX = (int)x;
+    this->ballAccelY = (int)y;
+//    this->printDouble(x, 20, 15);
+//    this->printDouble(y, 20, 25);
 }
 
-void Game::tick() {  
+void Game::tick() {
+    int tcount = 0;
     this->checkButtons();
     
     if (this->mode) {
+        if ((tcount % 10) == 0) {
+          this->readAccel();
+        };
         this->clearBall();
-        this->readAccel();
         this->updateBall();
         this->checkCollision();
         this->drawBall();
         this->checkPwm();
         this->checkLives(); 
-        wait_ms(25);
+        tcount++;
+        //wait_ms(1);
+        
     }
     else {    
         double x, y, z;
@@ -220,17 +229,17 @@
 }
 
 void Game::clearBall() {   
-    //this->disp.fillRect(this->ballX - Game::BALL_RADIUS, ballY - Game::BALL_RADIUS, Game::BALL_RADIUS * 2, Game::BALL_RADIUS * 2, DisplayN18::BLACK);
+    this->disp.fillRect(this->ballX - Game::BALL_RADIUS, ballY - Game::BALL_RADIUS, Game::BALL_RADIUS * 2, Game::BALL_RADIUS * 2, DisplayN18::GREY);
     //this->disp.fillCircle(this->ballX - Game::BALL_RADIUS, this->ballY - Game::BALL_RADIUS, Game::BALL_RADIUS, DisplayN18::BLACK);
-    this->disp.fillCircle(this->ballX, this->ballY, Game::BALL_RADIUS, DisplayN18::BLACK);
-    this->disp.setPixel(this->ballX, this->ballY, DisplayN18::BLACK);
+    //this->disp.fillCircle(this->ballX, this->ballY, Game::BALL_RADIUS, DisplayN18::GREY);
+    //this->disp.setPixel(this->ballX, this->ballY, DisplayN18::GREY);
 }
 
 void Game::drawBall() {
-    //this->disp.fillRect(this->ballX - Game::BALL_RADIUS, ballY - Game::BALL_RADIUS, Game::BALL_RADIUS * 2, Game::BALL_RADIUS * 2, DisplayN18::RED);
+    this->disp.fillRect(this->ballX - Game::BALL_RADIUS, ballY - Game::BALL_RADIUS, Game::BALL_RADIUS * 2, Game::BALL_RADIUS * 2, DisplayN18::RED);
     //this->disp.fillCircle(this->ballX - Game::BALL_RADIUS, ballY - Game::BALL_RADIUS, Game::BALL_RADIUS, DisplayN18::RED);
-    this->disp.fillCircle(this->ballX, ballY, Game::BALL_RADIUS, DisplayN18::RED);
-    this->disp.setPixel(this->ballX, this->ballY, DisplayN18::GREEN);
+    //this->disp.fillCircle(this->ballX, ballY, Game::BALL_RADIUS, DisplayN18::RED);
+    //this->disp.setPixel(this->ballX, this->ballY, DisplayN18::GREEN);
 }
 
 void Game::updateBall() {