Example #1
0
        private void StartNewGame()
        {
            ship = new Spaceship(Content);
            camera = new SpaceshipCamera(graphics.GraphicsDevice.Viewport, ship);

            int x, y, z, pos_x, pos_y, pos_z;
            Random random = new Random();

            for (int i = 0; i < NUM_ASTEROIDS; ++i)
            {
                x = random.Next(2);
                z = random.Next(2);
                y = random.Next(2);

                pos_x = random.Next(-30, 31);
                pos_y = random.Next(-30, 31);
                pos_z = random.Next(-30, 31);

                asteroids[i] = new Asteroid(Content, new Vector3(x, y, z));
                asteroids[i].Position = new Vector3(pos_x, pos_y, pos_z);
            }

            spriteDrawer = new SpriteDrawer(device, Content);
            spriteManager = new SpriteManager(device, Content);

            spFont = Content.Load<SpriteFont>(@"Arial");
            spBatch = new SpriteBatch(graphics.GraphicsDevice);

            particleSystem = new ParticleSystem(spriteManager);
            jetParticleEffect = new JetParticleEffect(particleSystem, ship);

            points = 0;
            jetParticleEffect.MinXDirection = -0.3f;
            jetParticleEffect.MaxXDirection = 0.3f;
            jetParticleEffect.MinZDirection = 0.6f;
            jetParticleEffect.MaxZDirection = 0.8f;
            jetParticleEffect.MinYDirection = -0.2f;
            jetParticleEffect.MaxYDirection = 0.2f;
            jetParticleEffect.ParticlesPerSecond = 50.0;
            jetParticleEffect.ParticleLifetime = 400.0;
            jetParticleEffect.ParticleSize = 0.5f;
            jetParticleEffect.ParticleSpeed = 0.7f;
            jetParticleEffect.FinalColor = Color.Red;
        }
Example #2
0
        private void FireNewMissile()
        {
            Missile missile = new Missile(Content, ship);
            missiles.Add(missile);

            var effect = new JetParticleEffect(particleSystem, missile);
            effect.MinXDirection = 0.6f;
            effect.MaxXDirection = 0.8f;
            effect.MinZDirection = -0.025f;
            effect.MaxZDirection = 0.025f;
            effect.MinYDirection = -0.025f;
            effect.MaxYDirection = 0.025f;
            effect.ParticlesPerSecond = 30.0;
            effect.ParticleLifetime = 2000.0;
            effect.ParticleSize = 0.2f;
            effect.ParticleSpeed = 5.0f;

            missileEffects.Add(effect);
            missileEffectsByMissile.Add(missile, effect);
        }