Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable rise speed for special riser #3005

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/object/specialriser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#include "supertux/sector.hpp"
#include "video/drawing_context.hpp"

SpecialRiser::SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> child, bool is_solid) :
SpecialRiser::SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> child, bool is_solid, float rise_speed) :
m_start_pos(pos),
m_offset(0),
m_child(std::move(child))
m_child(std::move(child)),
m_rise_speed(rise_speed)
{
m_child->set_pos(pos - Vector(0,32));
set_pos(m_start_pos);
Expand All @@ -41,7 +42,7 @@ SpecialRiser::SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> chil
void
SpecialRiser::update(float dt_sec)
{
m_offset += 50 * dt_sec;
m_offset += m_rise_speed * dt_sec;
set_pos(m_start_pos - Vector(0, m_offset));
if (m_offset > 32) {
Sector::get().add_object(std::move(m_child));
Expand Down
3 changes: 2 additions & 1 deletion src/object/specialriser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class SpecialRiser final : public MovingObject
{
public:
SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> child, bool is_solid = false);
SpecialRiser(const Vector& pos, std::unique_ptr<MovingObject> child, bool is_solid = false, float rise_speed = 50.0f);
virtual GameObjectClasses get_class_types() const override { return MovingObject::get_class_types().add(typeid(SpecialRiser)); }
virtual bool is_saveable() const override {
return false;
Expand All @@ -45,6 +45,7 @@ class SpecialRiser final : public MovingObject
Vector m_start_pos;
float m_offset;
std::unique_ptr<MovingObject> m_child;
float m_rise_speed;

private:
SpecialRiser(const SpecialRiser&) = delete;
Expand Down
Loading