I have a hero object that can be in many states and I am wonder what the best technique or at least a technique for handling them all. Just to name a few:
hero.isSpawning
hero.isRotating
hero.isDead
hero.isCrazy
hero.isSlow
hero.isInvinsible
Game logic depends on these flags to determine what he can and can’t do. For example, if he is rotating I prevent the gamer from moving him. If he is spawning nothing can eat him etc… But having all these flags gets confusing in the code and occasionally one of these flags gets stuck on and the game is all hung up. Like he never completes rotating.
I feel like I need a way to define allowable state transitions and then some kind of class that enforces these rules.
I am sure this is a common problem that has been solved many times. Would someone please point me to an example or two. I saw some Java and Python ones on the internet but can’t really follow those since I am not a Java nor Python programmer.
L