Graphics Programs Reference
In-Depth Information
Figure 6-7 . Spawning enemies
As we have modeled the Enemy object in Blender, we can obtain its center -
{10.0005, 10.0, 0.1005} by reading the global median value from the prop-
erties shelf , as shown in Figure 5-9.
Here, the static field _enemies is initialized as:
private static List<Enemy> _enemies = new
Although the _enemies ArrayList is initialized with an initial capacity of ten,
only four Enemy objects are actually used ( Figure 6-7 ). Now, let me describe how
this ArrayList is used in the Renderer class.
Recall that in the Tank Fence game, the player has to guard the (white) square region
against Enemy objects. Because of the way this object has been modeled in Blender
(Figure 5-9), its default position upon rendering is as shown in Figure 6-6 . So, we
need to push the Enemy objects away from the white region—as shown in Figure
6-7 . As you may have guessed, the way we do this is by translating these objects.
The values passed to the constructor for the Enemy class ( Listing 6-16 ) are used to
translate the matrix enemiesMMatrix , seen in Listing 6-17 (lines of code from
the onDrawFrame() method, Renderer class).
Search WWH ::

Custom Search