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
  • PrintPrint
Share this Page URL
Help

Jump Start CoffeeScript > 4. Game Loop and Classes

Chapter 4
Game Loop and Classes

It’s now day 4 of 7 and you’re starting to sweat. The story writer announced he has too much “real” work on and will have to bow out of the race, but says he still wants a cut of any profits arising from his contributions to the project. You explain to him how percentages of zero work, and he leaves in a huff.

You know that if you lack a solid base to build on by the end of the day, pushing a complete product out the door will be tough. Let’s knuckle down and apply some structure to our game. In this chapter, we’ll take the prototype we’ve been working on and refactor it into a bunch of classes that will organize and drive the game.

The Game Loop

But first, we need to clean up our mess from last night. In our haste to put some animation on the screen, we used the simple setInterval timer to continually loop over the updating and drawing methods. This morning, we’ll need to rework this into what will become the very heart of our game: the game loop.


  

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


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint