nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
StateManager Class Reference

Giga-class that switches from game states. More...

#include <StateManager.hpp>

Public Member Functions

 StateManager ()
 Initializes pretty much everything.
 
void run ()
 Main entry point and game loop.
 

Detailed Description

Giga-class that switches from game states.

It makes the transitions between them, assuring each one is properly initialized.

For developers:

Short and simple explanation:

  • Creates the first state (allocating everything).
  • Run it (updating and drawing).
  • Whenever the state feels like changing, it will tell us (quit, for example).
  • Then we must delete the current state and repeat this whole process for the next one.

Definition at line 22 of file StateManager.hpp.

Constructor & Destructor Documentation

◆ StateManager()

StateManager::StateManager ( )

Initializes pretty much everything.

Definition at line 8 of file StateManager.cpp.

◆ ~StateManager()

StateManager::~StateManager ( )
virtual

Definition at line 16 of file StateManager.cpp.

Member Function Documentation

◆ run()

void StateManager::run ( )

Main entry point and game loop.

This is where it all happens. The game never leaves this method, the only thing that's allowed to happen are state-specific methods called inside here.

If we leave this method, the game quits, as seen on main.cpp.

Definition at line 23 of file StateManager.cpp.


The documentation for this class was generated from the following files: