Graphics Programs Reference
In-Depth Information
Figure 6-6 . Boundaries for missiles
The Enemy Class
To work with the Enemy class, import the archive file Chapter6/tankfence-
game4.zip . This will load the TANK FENCE GAME 4 application into your
Eclipse workspace.
The src folder for this application contains the file Enemy.java . The Enemy class
is almost identical to the Missile class - except that the fields _angleZ and _in-
terceptY are not used in the Enemy class.
Spawning Enemies
Now, turn your attention to the lines of code ( Listing 6-16 ) in the onSur-
faceCreated() method in the Renderer class. The intent here is to place an
Enemy object in each quadrant, in such a way that they spawn at the corners of a
square - as shown in Figure 6-7 .
Listing 6-16. TANK FENCE GAME 4/src/com/apress/android/tankfencegame4/
GLES20Renderer.java
// 10.0005, 10.0, 0.1005
GLES20Renderer._enemies.add(new Enemy(10.0005f, 10.0f,
0));
GLES20Renderer._enemies.add(new Enemy(-3 * 10.0005f,
10.0f, 0));
GLES20Renderer._enemies.add(new Enemy(-3 * 10.0005f,
-3 * 10.0f, 0));
GLES20Renderer._enemies.add(new Enemy(10.0005f, -3 *
10.0f, 0));
 
 
 
Search WWH ::




Custom Search