Game Development Reference
In-Depth Information
The last thing we do is to call the player.renderCurrentTile function. Recall this
function from the discussion of the BlitSprite class too? If not, take a look at it again. If
the player.doCopyPixels Boolean is set to true , the tank tracks will animate by copying
the corresponding pixels from the tileSheet to the bitmapData attribute of the bitmap
object inside the BlitSprite instance (in this case, the player).
Notice that we have the setCurrentRegion function call commented out. We will be
using this soon.
Testing iteration 4
When you run this iteration, you will find that the player tank can travel tile by tile smoothly around
the screen and enter and exit tunnels on the other side (see Figure 7-3 for a screen shot of this
iteration). Notice that the tank will not appear to stop if you hold down the movement keys while it
moves between tiles. Also, if the tank is moving up and you want it to move into an open tunnel to
the left (for example), you must take your finger off of the up key and press the left key. The tank
will smoothly turn without stopping.
We have now completed the bulk of the code for moving game characters. The enemy tank code
will be very similar. We will take a look at that briefly and go into the “good enough” enemy Tank
AI in the next set of Iterations.
Figure 7-3. Iteration 4's game screen
Search WWH ::




Custom Search