moving to magnum
This commit is contained in:
38
Pipe.cpp
Normal file
38
Pipe.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user