A Bullets Collection

For the bullets, there's really nothing else left to do; however, you will probably store numerous bullets to render and update throughout the game play. It is probably useful to have a collection class to store the bullets in. Go ahead and add the Bullets class (in Listing 15.7) to this same code file.

Listing 15.7. The Bullets Collection
 /// <summary> /// A collection of bullets /// </summary> public class Bullets : IEnumerable { private ArrayList bulletList = new ArrayList(); /// <summary> /// Indexer for bullets /// </summary> public Bullet this[int index] { get { return bulletList[index] as Bullet; } set { bulletList[index] = value; } } /// <summary> /// Add a new bullet to the list /// </summary> public void Add(Bullet ...

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.