Monkey Game Development:Beginner's Guide
上QQ阅读APP看书,第一时间看更新

Detailing the Update process

In both events of the RocketCommander class, OnUpdate and OnRender, we will use a finite state machine (FSM) approach.

If you don't know what a finite state machine is, here is a link to a nice explanation:

http://en.wikipedia.org/wiki/Finite-state_machine.

An FSM does different things at anyone time, depending on which mode it is in. Consider the OnUpdate method of a Monkey game. Let's say the mode is the 'start' of a new game. Through IF checks or SELECT statements, you would call different methods or functions, as compared to when the mode was set to 'play' the game.

And in our case, depending on our variable gameMode, we will call different methods. It is one way of controlling and also structuring code. So, spice it up a little!