public void Draw(Camera camera)
        {
            graphicsDevice.SetVertexBuffer(particleVertexBuffer);

            // Only draw if there are live particles
            if (endOfLiveParticlesIndex - endOfDeadParticlesIndex > 0)
            {
                for (int i = endOfDeadParticlesIndex; i < endOfLiveParticlesIndex; ++i)
                {
                    particleEffect.Parameters["WorldViewProjection"].SetValue(
                        camera.view * camera.projection);
                    particleEffect.Parameters["particleColor"].SetValue(vertexColorArray[i].ToVector4());

                    // Draw particles
                    foreach (EffectPass pass in particleEffect.CurrentTechnique.Passes)
                    {
                        pass.Apply();

                        graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(
                            PrimitiveType.TriangleStrip,
                            verts, i * 4, 2);

                    }
                }
            }
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Initialize Camera
            camera = new Camera(this, new Vector3(0, 0, 50),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            // Initialize model manager
            modelManager = new ModelManager(this);
            Components.Add(modelManager);

            base.Initialize();
        }
Exemple #3
0
        public void Draw(Camera camera)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect be in mesh.Effects)
                {
                    be.EnableDefaultLighting();
                    be.Projection = camera.projection;
                    be.View = camera.view;
                    be.World = GetWorld() * mesh.ParentBone.Transform;
                }
                mesh.Draw();
            }
        }
Exemple #4
0
        public void Drew(Camera camera)
        {
            graphicsDevice.SetVertexBuffers(particleVertexBuffer);

            for (int i = 0; i < maxParticles; ++i)
            {
                particleEffect.Parameters["WorldViewProjection"].SetValue(
                    camera.view * camera.projection);
                particleEffect.Parameters["particleColor"].SetValue(
                    vertexColorArray[i].ToVector4());

                //Drew particles
                foreach (EffectPass pass in particleEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(
                        PrimitiveType.TriangleStrip,
                        verts, i * 4, 2);
                }
            }
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            // Clear border between screens
            GraphicsDevice.Clear(Color.Black);

            // Set current drawing camera for player 1
            // and set the viewport to player 1's viewport,
            // then clear and call base.Draw to invoke
            // the Draw method on the ModelManager component
            currentDrawingCamera = camera1;
            GraphicsDevice.Viewport = camera1.viewport;

            base.Draw(gameTime);

            // Set current drawing camera for player 2
            // and set the viewport to player 2's viewport,
            // then clear and call base.Draw to invoke
            // the Draw method on the ModelManager component
            currentDrawingCamera = camera2;
            GraphicsDevice.Viewport = camera2.viewport;

            base.Draw(gameTime);
        }
Exemple #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            camera = new Camera(this, new Vector3(0, 0, 50),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            //Intilize the Model manager
            modelManager = new ModelManager(this);
            Components.Add(modelManager);

            modelManager.Enabled = false;
            modelManager.Visible = false;

            //Splash screen component
            splashScreen = new SplashScreen(this);
            Components.Add(splashScreen);
            splashScreen.SetData("Welcome to space Defender!",
                currentGameState);

            base.Initialize();
        }
 public override void Draw(Camera camera)
 {
     if (isAlive)
         base.Draw(camera);
 }
Exemple #8
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //Intialize the video player
              //   vidPlayer = new VideoPlayer();

            camera = new Camera(this, new Vector3(0, 0, 50),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            //Intilize the Model manager
            modelManager = new ModelManager(this);
            Components.Add(modelManager);

            modelManager.Enabled = false;
            modelManager.Visible = false;

            //Splash screen component
            splashScreen = new SplashScreen(this);
            Components.Add(splashScreen);
            splashScreen.SetData("Welcome to space Defender!", currentGameState);
            splashScreen.Visible = false;

            //start menu
            startMenu = new StartMenu(this);
            Components.Add(startMenu);

            //about page
            about = new About(this);
            Components.Add(about);
            about.Visible = false;
            about.Enabled = false;

            //instructions page
            instructions = new Instructions(this);
            Components.Add(instructions);
            instructions.Visible = false;
            instructions.Enabled = false;

            base.Initialize();
        }
Exemple #9
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            camera = new Camera(this, new Vector3(0, 0, 50),
                Vector3.Zero, Vector3.Up);
            Components.Add(camera);

            modelManager = new ModelManager(this);
            Components.Add(modelManager);
            camera.addModelManager(modelManager);
            soundManager = new SoundManager();
            modelManager.setSoundManager(soundManager);

            debug = new Developer_Debug_Menu(this);

            oldState = Keyboard.GetState();
            oldGamepadState = GamePad.GetState(PlayerIndex.One);

            modelManager.Enabled = false;
            modelManager.Visible = false;

            //Splash screen component
            splashScreen = new SplashScreen(this);
            Components.Add(splashScreen);
            splashScreen.setSoundManager(soundManager);

            base.Initialize();
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Create viewports
            Viewport vp1 = GraphicsDevice.Viewport;
            Viewport vp2 = GraphicsDevice.Viewport;
            vp1.Height = (GraphicsDevice.Viewport.Height / 2);

            vp2.Y = vp1.Height;
            vp2.Height = vp1.Height;

            // Add camera components
            camera1 = new Camera(this, new Vector3(0, 0, 50),
                Vector3.Zero, Vector3.Up, vp1);
            Components.Add(camera1);

            camera2 = new Camera(this, new Vector3(0, 0, -50),
                Vector3.Zero, Vector3.Up, vp2);
            Components.Add(camera2);

            // Initialize model manager
            modelManager = new ModelManager(this);
            Components.Add(modelManager);

            base.Initialize();
        }