Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. Game #2, Rocket Commander > Detailing the Update process

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!


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial