Tank Properties

If you remember earlier when you first defined the tank class, plenty of variables declared were private and you didn't have any public way to access them. Naturally, you need to rectify this situation because the game engine (and player objects you will be creating) need to manipulate the tanks. Add the properties in Listing 13.10 to your tank class to round out its implementation.

Listing 13.10. Tank Properties
 public Vector3 Position { get { return tankPosition; } set { tankPosition = value; } } public float GunTurretAngle { get { return turretAngle; } set { if (value > MaxTurretAngle) turretAngle = (float)MaxTurretAngle; else if (value < MinTurretAngle) turretAngle = (float)MinTurretAngle; else turretAngle = value; } } public ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.