Simplify
This commit is contained in:
parent
890d061a92
commit
ee3c7c61db
2 changed files with 2 additions and 11 deletions
11
lib/Game.cpp
11
lib/Game.cpp
|
@ -14,22 +14,16 @@ Game::Game() {
|
|||
score.lives = DEFAULT_LIVES;
|
||||
}
|
||||
|
||||
auto Game::now() {
|
||||
return std::chrono::system_clock::now();
|
||||
}
|
||||
|
||||
void Game::run() {
|
||||
|
||||
const std::chrono::milliseconds delta_time(1000 / 60);
|
||||
|
||||
std::chrono::milliseconds t(0);
|
||||
std::chrono::milliseconds accumulator(0);
|
||||
auto current_time = now();
|
||||
auto current_time = std::chrono::system_clock::now();
|
||||
|
||||
InputState inputState;
|
||||
|
||||
while (true) {
|
||||
auto newTime = now();
|
||||
auto newTime = std::chrono::system_clock::now();
|
||||
auto frameTime = std::chrono::duration_cast<std::chrono::milliseconds>(newTime - current_time);
|
||||
current_time = newTime;
|
||||
accumulator += frameTime;
|
||||
|
@ -39,7 +33,6 @@ void Game::run() {
|
|||
while (accumulator >= delta_time) {
|
||||
step(delta_time, inputState);
|
||||
accumulator -= delta_time;
|
||||
t += delta_time;
|
||||
}
|
||||
canvas.update(gameState, score);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ private:
|
|||
void eatPellets();
|
||||
void processEvents(InputState & inputState);
|
||||
void checkCollision(Ghost & ghost);
|
||||
|
||||
[[nodiscard]] static auto now();
|
||||
};
|
||||
|
||||
} // namespace pacman
|
||||
|
|
Loading…
Reference in a new issue