#include #include "Bird.h" Bird::Bird(float x, float y, const std::shared_ptr> texture_list) : position(x, y), texture_list(texture_list), momentum(1.0) { sprite = sf::Sprite(texture_list->at(0)); sprite.setPosition(position); } void Bird::impulse(float p) { momentum = -p; } void Bird::tick(float step) { momentum += gravity * step; // Impart gravity position.y += momentum; sprite.setPosition(position); } void Bird::draw(sf::RenderTarget &target, sf::RenderStates states) const { target.draw(sprite, states); } bool Bird::collides(sf::FloatRect bounds) { return sprite.getGlobalBounds().intersects(bounds); }