sf::FloatRect gb {sprite.getGlobalBounds()};
sprite.setOrigin(gb.width / 2, gb.height / 2);
sprite.setPosition(position);
+
+ sack_texture.loadFromFile("assets/sack.png");
+ sack.setTexture(sack_texture);
+ sack.setScale(0.5, 0.5);
+
+ sf::FloatRect gb_s {sack.getGlobalBounds()};
+ sack.setOrigin(gb_s.width / 2, gb_s.height / 2);
+ sack_offset = {gb.width/4, -gb.height/15};
+ sack.setPosition(position + sack_offset);
+
}
Game_state* game = static_cast<Game_state*>(context.current_state.get());
position += max_speed * direction;
-
+
sprite.setPosition(position);
+ sack.setPosition(position + sack_offset);
return;
}
void Player::render(sf::RenderWindow& window) const
{
window.draw(sprite);
+ window.draw(sack);
}
void Player::handle_input(sf::Event& event)
private:
int collected;
float max_speed;
+ sf::Sprite sack;
+ sf::Texture sack_texture;
+ sf::Vector2f sack_offset; //{20, -30};
};
#endif
\ No newline at end of file