#include "Pipe.h" #include Pipe::Pipe(float x, float y, std::shared_ptr pipe_top_texture_s, std::shared_ptr pipe_shaft_texture_s, std::shared_ptr pipe_shaft_shader_s) : position(x, y), pipe_top_texture(std::move(pipe_top_texture_s)), pipe_shaft_texture(std::move(pipe_shaft_texture_s)), pipe_shaft_shader(std::move(pipe_shaft_shader_s)), momentum(1.0) { pipe_top = sf::Sprite(*pipe_top_texture); pipe_shaft = sf::Sprite(*pipe_shaft_texture); pipe_top.setPosition(position); } void Pipe::tick(float step, float speed) { position.x += step * speed; pipe_top.setPosition(position); auto pos = pipe_top.getPosition(); pos.y += 25; pipe_shaft.setPosition(pos); } void Pipe::draw(sf::RenderTarget &target, sf::RenderStates states) const{ states.shader = &*pipe_shaft_shader; target.draw(pipe_top, states); target.draw(pipe_shaft, states); } bool Pipe::collides(sf::FloatRect bounds) { return false; }