Beispiel #1
0
 /// <summary>
 /// Calculate the physics for the ship.
 /// This includes the ship's position, rotation, physics, particles,
 /// and projectiles.
 /// </summary>
 /// <param name="width">Game board width</param>
 /// <param name="height">Game board height</param>
 public void CalculatePhysics(int width, int height)
 {
     CalculateProjectiles(width, height);
     CalculatePosition(width, height);
     CalculateRotation();
     ResetPhysics();
     shipStream.CalculateParticles(DELTA_SHIP_STREAM);
 }
Beispiel #2
0
        /// <summary>
        /// Determines physics for projectiles and its particles for the frame.
        /// Projectile is removed if it travels off screen.
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        private void CalculateProjectiles(int width, int height)
        {
            projectileStream.CalculateParticles(DELTA_PROJECTILE_STREAM);

            // determine projectiles
            for (int i = 0; i < projectiles.Count; i++)
            {
                // projectile[i][0] = X position of projectile, [1] = Y position of projectile, [2] = rotation of projectile
                projectiles[i][0] += projectiles[i][4];
                projectiles[i][1] += projectiles[i][5];
                projectileStream.AddParticles(projectiles[i][0], projectiles[i][1], 0, 0, 3, 1, 2, 1);
                projectileStream.AddParticles(projectiles[i][0], projectiles[i][1], 0, 0, 3, 1, 2, 3);
                projectileStream.AddParticles(projectiles[i][0], projectiles[i][1], 0, 0, 3, 1, 1, 5);

                if ((projectiles[i][0] < 0) || (projectiles[i][0] > width) || (projectiles[i][1] < 0) || (projectiles[i][1] > height))
                {
                    projectiles.RemoveAt(i);
                }
            }
        }