Game Development Reference
In-Depth Information
Figure 13-10 . Duplicate the if-else structure from the isRight() structure into the isLeft() structure using frame-
counter
Now the time has come again to use the Run Project work process and test the
run-cycle code, which now exhibits a smooth, even, realistic run cycle. You can fine
tune the running speed to slightly slower with a 7 or 8 value or slightly faster with a 4
or 5 value. As we add faster vX values for running (say vX = 2) we can set the run-
ningspeed to 3 or 4 to match this and make the game far more realistic.
One additional thing that I noticed as I was testing the code during this chapter that
I want to correct here is the sprite cel image for landing. I have been using im-
ageStates(3), which is the “landed” image, which should actually be better utilized with
a collision situation. Let's save this sprite cel image state for use later, in the collision
detection code development phase, to signify a collision with a surface (just landed or
on impact image). The image I want to use while the down arrow key is pressed is ac-
tually imageStates(6) , which is the “preparing to land” image. The revised Java code
will look like the following, and is shown highlighted in Figure 13-11 :
 
 
Search WWH ::




Custom Search