when making a game with c++ and sfml, how does one go about organizing the multiple levels? In my game there will be multiple rooms, I plan on changing the room by changing the sf::View
, but I dont want a lengthy main.cpp that is unorganized, so do I make each room/level a separate function? Or make a class that manages the current room/level and just switches the room accordingly? Whats the best way to organize multiple levels in a sfml game? Thanks.
I decided to use an enum class, thanks for link and advice domsson. My enum class and switch statements look like:
int windowWidth = 5000;//width of window
int windowHeight = 5000;//height of window
sf::View leveltwo(sf::FloatRect(x, y, 5000, 5000));
sf::View start(sf::FloatRect(0, 0, 2500, 1500));
sf::RenderWindow window(sf::VideoMode(windowWidth, windowHeight ), "Awesome Game" );
enum Levels{
StartRoom, LevelTwo
};
Levels room = StartRoom;
void WhatRoom(int TheLevel){
switch (room){
case StartRoom:
window.setView(start);
if (TheLevel == 2){
room = LevelTwo;
}
case LevelTwo:
window.setView(leveltwo);
}
};
This is working very well.