void loop() { is_diff_game_mode(); // different game modes movePaddle(); render_ball(); render_right_wall(); render_score(); render_lives(); lBtn2 = GPIOPinRead(BTN2Port, BTN2); if (lBtn2 == BTN2) { render_credits(); } ballMove(); OrbitOledUpdate(); oledReset(); }
void Game::tick() { ballMove(); forceRacketIntoField(); while (true) { bool hit = false; Brick* pBrickRef = nullptr; HitRecord hr; HitRecord lhr; if (hitTopField(lhr) == true && lhr.getRollback() > hr.getRollback()) { hit = true; hr = lhr; } if (hitRightField(lhr) == true && lhr.getRollback() > hr.getRollback()) { hit = true; hr = lhr; } //Bottom border if (hitBottomField(lhr) == true && lhr.getRollback() > hr.getRollback()) { setBallOwner(); ballExit(); hr = lhr; break; } if (hitLeftField(lhr) && lhr.getRollback() > hr.getRollback()) { hit = true; hr = lhr; } hitRacket(lhr, hr, hit); pBrickRef = hitBrick(lhr, hr, hit); if (hit) { setBallPosition(hr); if (pBrickRef != nullptr) { pBrickRef->strength()--; incrementScore(); if (pBrickRef->strength() == 0) { removeBrick(pBrickRef); } } } else { break; } } }