I'm making a pong game with c++ that currently has two states, GameState and MenuState. The way it is now, both states are methods of the Game class. The Game class has all the instance data that both methods/states use (so paddles, ball, menu buttons, etc). Is it bad practice to make a gamestate a method rather than its own class?
This is how my main function is right now
#include "Game.h"
int main( int argc, char* args[] )
{
Game game;
game.Run();
return 0;
}
And the Run function
int Game::Run()
{
if (error)
{
return 1;
}
//The frame rate regulator, passed to GameState
Basic_SDL::Timer fps;
//Which player scored (left or right), passed to GameState
int scoreKeeper = 0;
rightPaddle.setAI(true);
//While the suer hasn't quit
while (quit == false)
{
if (!paused)
{
GameState(fps, scoreKeeper);
}
else
{
MenuState();
}
}
//Clean up
clean_up();
}
It works fine this way, I'm just not sure if making each state a method is looked down upon. Any other advice on how to implement game states would be appreciated also .