Skip to content

Commit

Permalink
Modified sprite_pos to be physics_pos.
Browse files Browse the repository at this point in the history
  • Loading branch information
A-rms committed Feb 16, 2024
1 parent f052055 commit 8f69def
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DogTales/dog/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Player::Player(bave::App& app, glm::vec2 const world_space) : m_app(app), m_worl
void Player::tick(bave::Seconds const dt) {

m_physics.tick(dt);
m_sprite.transform.position = m_physics.position;

auto const& key_state = m_app.get_key_state();
auto direction = glm::vec2{};
Expand All @@ -23,12 +22,13 @@ void Player::tick(bave::Seconds const dt) {
m_physics.position += displacement;
}
handle_wall_collision();
m_sprite.transform.position = m_physics.position;
}

void Player::draw(bave::Shader& shader) const { m_sprite.draw(shader); }

void Player::handle_wall_collision() {
auto& position = m_sprite.transform.position;
auto& position = m_physics.position;
// bounce_rect represents the play area for the sprite, ie the limits for its centre.
// the size is simply the total space minus the sprite size, centered at the origin.
// the second argument (glm::vec2{0.0f}) is the default value and can be omitted here.
Expand Down

0 comments on commit 8f69def

Please sign in to comment.