Object oriented SDL
Another day. Another question.
Alright guys I've successfully programmed a pong game in SDL and would like to now move on to making a pacman or something similar, but I have a question as to how to have a gamestate class that calls functions. I've thought about just having it contain the game state and having a pacman, ghost, and menu class take in the current state but having a get function in the game state class. But I'm afraid that then I will have a bunch of objects checking for updates and running a switch case.
I also thought that it would be easier to run everything from one swtich-case statement in the gamestate class.. and have it seperated to do input, then logic, and finally rendering, but the only problem with this is I would have to either pass every object instance to the gamestate class or make them all global(I know REALLY bad). So I guess my question is what's the correct approach. I've seen a few that suggest creating a hierarchy does this method involve all objects to be parented by the gamestate class. Hope this is clear.
Lazy Foo' Productions
Helpful article on State Machines, if you haven't already read it (considering you're talking about SDL, you probably have).
Try one approach or the other and when you run into problems and have a specific question ask it here.
The Lazy Foo design example works really well, but before just diving in with it, take time to think your game design through and how it would be implemented with the State Machine shown in the tutorial, as it is only one way to do it, and does have some limitations.