Skip to content

Add speedrun ghost mode#3805

Open
Davi-Azeredo wants to merge 2 commits into
SuperTux:masterfrom
baltazarReis:feature-speedrun-ghost
Open

Add speedrun ghost mode#3805
Davi-Azeredo wants to merge 2 commits into
SuperTux:masterfrom
baltazarReis:feature-speedrun-ghost

Conversation

@Davi-Azeredo

Copy link
Copy Markdown

Add optional SpeedRun ghost mode

This PR adds an optional speedrun mode where the player can race against a translucent replay of their best completed run in each level.

When enabled, the game records the player’s run and saves the best replay per level. On later attempts, a translucent ghost replays that run, including movement, direction, bonus state, and sprite animations.

The ghost is purely cosmetic and does not interact with physics, enemies, tiles, or world objects.

The HUD timer now also gives live feedback while racing the ghost, showing whether the player is ahead or behind with a time delta. The best replay is updated automatically whenever the player finishes the level faster.

Add an optional speedrun mode where the player can race against a
translucent replay of their best run in each level. The ghost follows
the recorded movement and animations, but remains purely visual and
does not interact with physics or world objects.

The HUD timer also shows whether the player is ahead or behind the
ghost during the run.

Co-authored-by: Baltazar Reis <baltazar.reis@tecnico.ulisboa.pt>
Comment thread src/worldmap/level_tile.cpp Outdated
} // namespace

void
LevelTile::set_best_ghost_run(std::vector<GhostRunPoint> best_ghost_run)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pass this by reference, please?

Comment thread src/worldmap/level_tile.hpp Outdated

inline const std::vector<GhostRunPoint>& get_best_ghost_run() const { return m_best_ghost_run; }
inline bool has_best_ghost_run() const { return !m_best_ghost_run.empty(); }
void set_best_ghost_run(std::vector<GhostRunPoint> best_ghost_run);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and change the parameter type here as well.

Comment thread src/supertux/game_session.cpp Outdated
static const float TELEPORT_SPEEDUP = 3.18f;

GameSession::GameSession(Savegame* savegame, Statistics* statistics) :
GameSession::GameSession(Savegame* savegame, Statistics* statistics, std::vector<worldmap::LevelTile::GhostRunPoint> best_ghost_run) :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should pass the vector by reference as well.

@Davi-Azeredo

Davi-Azeredo commented Jun 3, 2026

Copy link
Copy Markdown
Author

Sorry for the delay! I have now switched to reference instead of making new copies of the vector, which yeah I think is way cleaner. Thanks for the input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants