You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

#include "Pipe.h"
#include <utility>
Pipe::Pipe(float x, float y,
std::shared_ptr<sf::Texture> pipe_top_texture_s,
std::shared_ptr<sf::Texture> pipe_shaft_texture_s,
std::shared_ptr<sf::Shader> 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;
}