Wiki

Clone wiki

Potato / World

World Class

There's a World superclass that defines, well, a world. Each world is self-contained: it treats its logic, its input and its rendering. A world is nothing more than part of the game. The in-game section is a World (called GameWorld), the intro screen is another World (called IntroWorld), the car selection screen is another world (called PlayerSelect).

The World class has 5 virtual methods that should be implemented:

World(void)

Create the necessary variables that don't affect any kind of state here. All stuff created here should be destroyed in ~World(void).

~World(void)

Shutdowns the world. Cleans it all.

void setup(void)

Setups the world. The scene setup should be done here.

void pollEvent(SDL_Event* e) [Deprecated]

This method should be used ONLY if you need to get info (actuate accordingly) from a SDL_Event. The only use this method should have is to poll a Controller object. In the future this method shall be removed.

void processInput(float interpolation)

All input processing should be done in this method. This method is called by the Potato's main loop before processLogic is called.

void processLogic(float interpolation)

The world's game logic should be done here.

void renderScene(void)

Renders the scene. All audio and video rendering should be done here. Usually the matrices and viewports are setup and then a Scene object is used to aid in Entity rendering.

Updated