Now that we have all of the images and classes for the objects in the game, our next order of business is to build the game engine. Canvas Hero is built with a standard MVC architecture, which separates the data, the presentation, and the control methods. In this recipe, we'll create a Controller class which is responsible for instantiating the model and view, initializing the game, controlling the game state, and managing keyboard events.
Follow these steps to create the controller for Canvas Hero:
/* * Game controller * * The controller is responsible for instantiating * the view and the model, initializing the game, * controlling the game state, and managing keyboard ...