What to use instead switch in update() for a game engine
I was working on a game with simple Scene classes that have an update() method, which is called every time inside of the main game loop. In the first one, I have a cutscene where a bunch of events happen one after another. I set up a switch that handles whatever I need depending on the current step. Obviously, once it got past 3 steps, it became a pain to keep track of. I can't just wedge another event in the middle without manually renumbering all the hardcoded step numbers (int state). One option is an array of std::function, and some macros to make it look a little bit less complicated. But
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.