Of course, drawing the same frame over and over won't do any good. We need to update the game too. This includes responding to user input, checking for collisions, and moving us along the cave.
We'll be doing all our updating in… guess what—doUpdate
in www/js/app/views/gameView.js.
If you recall from the last task, the only incoming parameter is the incoming frame multiplier. We want this to be 1, but it might be 2 if we're getting 30 fps, or 4 if we're getting 15 fps. We'll use the frame multiplier at various points to multiply any updates so that everything moves as if we were getting 60 fps, even when we aren't. Let's use the following code for this purpose:
self._doUpdate = function ( f ) { var gameOver = false; var levelOver = false; var oldShip = {x: self._ship.x, y: self._ship.y };
The first step of our update process is to record the current value of the ship. We need this to properly detect collisions later as the position of our ship...