How to deal with long platformer levels?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Marty S

I am working on a simple 2d platformer, but with fast racing like movement. Think speed like Sonic the Hedgehog but faster. This means I go past the terrain/tilemaps pretty quickly.

I seem to hit some 2D editor limit of 20k pixels or something, and its a pain to continue panning to the right to extend the level and place more tiles to build the level.

Should I be programmatically creating the levels in some way or just loading scenes in a way that the player doesn’t notice to traverse long distances at high speed ?

:bust_in_silhouette: Reply From: Magso

There are two ways to go about this but both ways require splitting the level into parts as separate scenes that can seamlessly transition as the player runs across them.
The first way is to have parts of the level spawn and move across whilst the player and camera remain still on the X axis.
The other way is to have the player move across the level parts and at the end of each part teleport everything back the distance the part covered so the player is back to 0 on the X axis.
In both case the previous level part can call queue_free() when it’s out of view.

:bust_in_silhouette: Reply From: bluepandion

The 2D-editor view scrolling is only limited by the bounds of the scene objects. Probably to prevent the view from getting too far from the scene content.

You could just create one Sprite or Control that’s scaled to span 100,000 x 100,000 pixels (or whatever is necessary), then you can easily scroll inside that area.