Now, we are going to add another physics simulator with a different gravitational force to control dozens of meteors and to create the illusion of a meteors rain.
1. Stay in the
3DInvadersSilverlight
project,.2. Open
InvadersGame.cs
for the C# code.3. Add the following private variable in the
public class InvadersGame : RealTimeGame
, to hold anotherPhysicsSimulator
(FarseerGames.FarseerPhysics.PhysicsSimulator
) instance:private PhysicsSimulator _meteorsPhysicsSimulator;
4. Add the following lines of code at the beginning of the class definition (as we are going to use the
System.Collections.Generic.List
class):using System.Collections.Generic;
5. Add the following
private
variables to hold the list of meteors, the number of meteors to create and a random number generator:protected List<Meteor> _meteors; // A random generator protected Random _random = new Random(); // The number of meteors to create private int _meteorsNumber...