The Shield Class

From our game mechanics definition we know the size and behavior of our shield blocks. They just sit there in our world at some location, waiting to be annihilated by a shot either from our ship or an invader. There's not a lot of logic in them, so the code is rather concise. Listing 12-6 shows you a shield block's internals.

Listing 12-6., the Shield Block Class package com.badlogic.androidgames.droidinvaders;

import com.badlogic.androidgames.framework.GameObject3D;

public class Shield extends GameObject3D { static float SHIELD_RADIUS = 0.5f;

public Shield(float x, float y, float z) { super(x, y, z, SHIELD_RADIUS);

We defined the shield's radius and initialize its position and bounding sphere according to the constructor parameters. That's all there is to it!

0 0

Post a comment