Exemplo n.º 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create the asteroid manager using the following parameters.
        /// </summary>
        /// <param name="game">
        /// The instantiating game.
        /// </param>
        /// <param name="number">
        /// The total number of asteroids to spawn.
        /// </param>
        /// <param name="minDist">
        /// The minimum distance from the center of the universe for our generation.
        /// </param>
        /// <param name="maxDist">
        /// The maximum distance from the center of the universe for our generation.
        /// </param>
        /// <param name="minHeight">
        /// The minimum possible height to use for our asteroids.
        /// </param>
        /// <param name="maxHeight">
        /// The maximum possible height to use for our asteroids.
        /// </param>
        public static void Create(Game1 game, int number, float minDist, float maxDist, float minHeight, float maxHeight)
        {
            Asteroids = new List<Planet>();

            Texture2D texture = game.Content.Load<Texture2D>("Textures/meteor1");

            for (int iteration = 0; iteration < number; iteration++)
            {
                // First, determine a random angle between 0 and 2pi and a random height
                float height = RandomHelper.RandomFloat(minHeight, maxHeight);

                float distanceX = RandomHelper.RandomFloat(minDist, maxDist);
                float distanceZ = RandomHelper.RandomFloat(minDist, maxDist);

                // Determine a base angle from iteration then add a variance
                float variance = RandomHelper.RandomFloat(0, 100) / 100.0f;
                float angle = (float)(iteration % 20);
                angle += variance;

                Planet asteroid = new Planet(game, "Models/asteroid" + RandomHelper.RandomInt(1, 2))
                {
                    Texture = texture,
                    Scale = new Vector3(0.00008f),

                    Origin = new Vector3((float)Math.Cos(angle) * distanceX, height, (float)Math.Sin(angle) * distanceZ),
                    Spin = new Vector3(RandomHelper.RandomFloat(0, 2.0f * 3.14f),
                    RandomHelper.RandomFloat(0, 2.0f * 3.14f), RandomHelper.RandomFloat(0, 2.0f * 3.14f)),
                    Orbit = new Vector3(1.0f, 0, 0),
                };

                Console.WriteLine(asteroid.Origin);

                Asteroids.Add(asteroid);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// A constructor accepting the instantiating game.
        /// </summary>
        /// <param name="game">The game that is instantiating this node.</param>
        public ANode(Microsoft.Xna.Framework.Game game)
        {
            this.Game = (Game1)game;
            this.GraphicsDevice = game.GraphicsDevice;

            this.Scale = new Vector3(1, 1, 1);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="game"></param>
        /// <param name="position">Position in game world.</param>
        /// <param name="target">Position to be looking up.</param>
        /// <param name="up">Orientation.</param>
        public StaticCamera(Game1 game, Vector3 position, Vector3 target, Vector3 up)
        {
            View = Matrix.CreateLookAt(position, target, up);

            Projection = Matrix.CreatePerspectiveFieldOfView((float)game.Window.ClientBounds.Width / (float)game.Window.ClientBounds.Height,
                MathHelper.PiOver2,
                1,
                1000);
        }
Exemplo n.º 5
0
 /// <summary>
 /// A constructor accepting an instantiating game.
 /// </summary>
 /// <param name="game">The game that is instantiating this planet.</param>
 public Planet(Game1 game, string model = null)
     : base(game, model != null ? model : "Models/sphere")
 {
     Satellites = new List<Planet>();
 }