O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required