Skip to content

Commit

Permalink
Fix compilation with the latest version of nCine
Browse files Browse the repository at this point in the history
- Rename the interval method of the application class
  • Loading branch information
encelo committed Feb 24, 2025
1 parent f70b954 commit eabf029
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/EnemyPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void EnemyPool::reset()
lastShootTime_ = nc::TimeStamp::now();
}

void EnemyPool::update(float interval)
void EnemyPool::update(float frameTime)
{
// Bounding box of alive enemies
xMin_ = nc::theApplication().width();
Expand Down Expand Up @@ -80,12 +80,12 @@ void EnemyPool::update(float interval)
{
case MOVE_RIGHT:
{
enemy.moveX(roundf(interval * horizontalSpeed_));
enemy.moveX(roundf(frameTime * horizontalSpeed_));
break;
}
case MOVE_LEFT:
{
enemy.moveX(-roundf(interval * horizontalSpeed_));
enemy.moveX(-roundf(frameTime * horizontalSpeed_));
break;
}
case MOVE_DOWNRIGHT:
Expand Down
2 changes: 1 addition & 1 deletion src/EnemyPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EnemyPool
void reset();

/// Updates positions, transitions states and calculates the bounding box
void update(float interval);
void update(float frameTime);
/*! \note This is the only drawing method that contains logic to use more than a single sprite for pool entities */
void draw();

Expand Down
12 changes: 6 additions & 6 deletions src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Game::Game()

Game::~Game() = default;

void Game::update(float interval)
void Game::update(float frameTime)
{
switch (state_)
{
Expand All @@ -65,17 +65,17 @@ void Game::update(float interval)
screenString_.format("Score: %u - Lives: %u", player_->score(), player_->lives());
screenText_->setString(screenString_);

bombPool_->updateBombs(interval);
bombPool_->updateBombs(frameTime);
bombPool_->draw();
enemyPool_->update(interval);
enemyPool_->update(frameTime);
enemyPool_->draw();
rocketPool_->updateRockets(interval);
rocketPool_->updateRockets(frameTime);
rocketPool_->draw();

if (playerMovement_ == PlayerMovement::RIGHT)
player_->move(interval);
player_->move(frameTime);
else if (playerMovement_ == PlayerMovement::LEFT)
player_->move(-interval);
player_->move(-frameTime);

bool rocketEnemyCollision = CollisionManager::performCollisions(rocketPool_.get(), enemyPool_.get());
bool bombPlayerCollision = CollisionManager::performCollisions(player_.get(), bombPool_.get());
Expand Down
2 changes: 1 addition & 1 deletion src/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Game

Game();
~Game();
void update(float interval);
void update(float frameTime);
inline void reset() { state_ = GameState::START; }
void togglePause();

Expand Down
4 changes: 2 additions & 2 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Player::Player(ProjectilePool *rocketPool, nc::Texture *playerTexture)
reset();
}

void Player::move(float interval)
void Player::move(float frameTime)
{
sprite_.moveX(roundf(interval * Conf::PlayerSpeed));
sprite_.moveX(roundf(frameTime * Conf::PlayerSpeed));

// Clamping to window horizontal borders
if (sprite_.position().x < 0.0f)
Expand Down
2 changes: 1 addition & 1 deletion src/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Player
Player(ProjectilePool *rocketPool, nc::Texture *playerTexture);

/// Move the player by an amount specified by the time passed since last frame
void move(float interval);
void move(float frameTime);
void shoot();

inline unsigned int lives() const { return lives_; }
Expand Down
8 changes: 4 additions & 4 deletions src/ProjectilePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ bool ProjectilePool::shoot(float x, float y)
return (projectile != nullptr);
}

void ProjectilePool::updateBombs(float interval)
void ProjectilePool::updateBombs(float frameTime)
{
// Traverse the array backwards to release sprites
for (int i = projectiles_.acquiredSize() - 1; i >= 0; i--)
{
projectiles_[i].moveY(-roundf(interval * Conf::BombSpeed));
projectiles_[i].moveY(-roundf(frameTime * Conf::BombSpeed));
if (projectiles_[i].position().y + projectiles_.spriteHeight() * 0.5f < 0.0f)
projectiles_.release(i);
}
}

void ProjectilePool::updateRockets(float interval)
void ProjectilePool::updateRockets(float frameTime)
{
// Traverse the array backwards to release sprites
for (int i = projectiles_.acquiredSize() - 1; i >= 0; i--)
{
projectiles_[i].moveY(roundf(interval * Conf::RocketSpeed));
projectiles_[i].moveY(roundf(frameTime * Conf::RocketSpeed));
if (projectiles_[i].position().y - projectiles_.spriteHeight() * 0.5f > nc::theApplication().height())
projectiles_.release(i);
}
Expand Down
4 changes: 2 additions & 2 deletions src/ProjectilePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class ProjectilePool
bool shoot(float x, float y);

/// Updates positions and returns to the pool a bomb that goes beyond the bottom of the window
void updateBombs(float interval);
void updateBombs(float frameTime);
/// Updates positions and returns to the pool a rocket that goes beyond the top of the window
void updateRockets(float interval);
void updateRockets(float frameTime);

void draw();
void reset();
Expand Down
4 changes: 2 additions & 2 deletions src/invaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void MyEventHandler::onFrameStart()
else if (axisValue < -nc::IInputManager::LeftStickDeadZone)
game_->movePlayer(Game::PlayerMovement::LEFT);

const float interval = nc::theApplication().interval();
game_->update(interval);
const float frameTime = nc::theApplication().frameTime();
game_->update(frameTime);
}

#ifdef __ANDROID__
Expand Down

0 comments on commit eabf029

Please sign in to comment.