Some random attempts at programming the retro console
Fork of RETRO_Pong_Mod by
Diff: Game.cpp
- Revision:
- 5:8a26ad9d9ea1
- Parent:
- 4:84be90860d7c
- Child:
- 6:20788dfdb7b8
--- a/Game.cpp Wed Feb 25 22:53:35 2015 +0000 +++ b/Game.cpp Wed Feb 25 23:28:49 2015 +0000 @@ -105,7 +105,7 @@ this->pwmTicksLeft = 0; this->lives = 4; this->score = 0; - this->muted = false; + this->muted = true; this->pwm.period(1); this->pwm.write(0.00); @@ -122,11 +122,19 @@ this->ballAccelY = 0; } +void Game::readAccel() { + double x, y, z; + this->getXYZ(x, y, z); + this->ballAccelX = floor(x); + this->ballAccelY = floor(y); +} + void Game::tick() { this->checkButtons(); if (this->mode) { this->clearBall(); + this->readAccel(); this->updateBall(); this->checkCollision(); this->drawBall(); @@ -226,6 +234,8 @@ } void Game::updateBall() { + this->ballSpeedX += this->ballAccelX; + this->ballSpeedY += this->ballAccelY; this->ballX += this->ballSpeedX; this->ballY += this->ballSpeedY; }