How to implement level transitioning for 2D Platformer (tile-based)

I'm making a 2D tile-based platformer in C++/SDL and I want the player to move to the next level when they run off the side of the level, but I'm not sure how to implement this. I have tried putting colliders on the tiles at the edge of the map but it seems like there could be a better than than designating special tiles.

I wasn't sure what to keywords to search for when looking for a solution so if you can point me to a useful guide that would be great!

I'm looking for something very similar to how Super Metroid handles level changing.

Without knowing any of the mechanics of your code it can be difficult to suggest a solution that is efficient, simple to integrate, and extendable. Please consider that when asking future questions. It would be a better use of time for the both of us to tailor an answer to your needs than to give general advice.

Now with that said, given free reign of the problem, I would approach it with the idea in mind that you may want to end levels through different scenarios in the future.

First I would create an interface specifically for that purpose.

Interface LevelFinisher {

finishLevel()

}


Then you have the ability to end the level in numerous ways. You could assign the functionality to an item that you use, a platform you hit, an enemy you kill, etc.

Now your original question suggested you want to end levels after reaching a certain point. Using your new interface you can create an object that is fed the player's position and checks to see if they have passed the x or y coordinate that marks the level's end. Then simply call that object's finishLevel() method.