Graphics Programs Reference
In-Depth Information
if(renderEnemy) {
float dx, dy;
Matrix.setIdentityM(enemiesMMatrix, 0);
Matrix.translateM(enemiesMMatrix, 0, enemyOX,
enemyOY, 0);
dx = enemyX - enemyOX;
dy = enemyY - enemyOY;
Matrix.translateM(enemiesMMatrix, 0, dx, dy, 0);
Inside the while block, initialize a ( boolean ) flag renderEnemy as true . If
any missile collides with the current Enemy object, this flag will be set to false ,
and the current Enemy object won't be rendered.
Note We are iterating over Enemy objects inside an ArrayList ,
so, the “current Enemy object” refers to the Enemy object being
while(enemiesIterator.hasNext()){...} block.
Next, you need to interpolate the source position of the current Enemy object. As
described in the previous section, while interpolating you also need to test if the cor-
responding Enemy object has entered the plane.
After interpolating the source position of the current Enemy object, start iterating
over the missiles. Create a local variable (of type Missile ) to reference the current
missile. Store the center of this missile by reading its interpolated source position.
Create another local variable difference , of type float[3] . Inside this vari-
able, store the difference between the centers of (current) missile and enemy objects.
Search WWH ::

Custom Search