Game Development Reference
In-Depth Information
private void setImageState() { The Method Body we'll
develop in this chapter goes in here }
Figure 13-1 . Create the private void setImageState() method; place a setImageState() method call in .update() meth-
od
As you can see in Figure 13-1 , this empty code framework doesn't generate any red
error or yellow warning highlights in the code. We are currently very organized, ac-
complishing all our KeyEvent handling, boundary detection, sprite animation, and
sprite movement, by using only four method calls inside of this Bagel class .update()
method.
The first thing that we want to check for is no movement: that is, no keys pressed,
so that we can correctly implement the “waiting” InvinciBagel state we used in the pre-
vious chapter to develop a sprite movement algorithm.
The InvinciBagel Wait State: If No Key Pressed Set
imageState(0)
The first conditional if() statement that we put into place will be the default or “no keys
pressed” state, which is sprite zero that shows the InvinciBagel waiting impatiently to
be moved and animated. What we want to look for inside of the if evaluation area in-
side of the parenthesis is a false value for each of the up, down, left, and right vari-
ables, all at the same moment of time. Up until now, we have been looking for a true
 
Search WWH ::




Custom Search