Exemplo n.º 1
0
        /// <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)
        {
            GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here

            Vector2 mousepos = Mouse.GetState().Position.ToVector2() - VPHalfSize;
            Vector2 drawpos  = player.Position + VPHalfSize;

            GraphicsDevice.SetRenderTargets(ZBuffer);

            player.Draw(spriteBatch, cameraMatrix);

            DrawQuad(ZBufferTargets[0], 0.0f, 0.0f, 0.5f, 0.5f, OutputTarget);
            DrawQuad(ZBufferTargets[1], 0.5f, 0.0f, 0.5f, 0.5f, OutputTarget);

            DrawQuad(OutputTarget);

            base.Draw(gameTime);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Function that gets al the drawing objects on the game
        /// </summary>
        /// <returns></returns>
        public Image GetFrame()
        {
            Image    imagem   = new Bitmap(ScreenWidth, ScreenHeight);
            Graphics graficos = Graphics.FromImage(imagem);

            foreach (Asteroid asteroide in this.AsteroidsList)
            {
                asteroide.Draw(graficos);
            }

            foreach (Shot tiro in player.shots)
            {
                tiro.Draw(graficos);
            }

            player.Draw(graficos);

            graficos.Dispose();
            return(imagem);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws all Entities to the screen
        /// </summary>
        /// <param name="gameTime">Time passed since the last call to Draw.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);


            _spriteBatch.Begin();

            if (_running)
            {
                _player.Draw(_spriteBatch);

                foreach (Projectile t in _projectiles)
                {
                    t.Draw(_spriteBatch);
                }

                foreach (Asteroid asteroid in _asteroids)
                {
                    asteroid.Draw(_spriteBatch);
                }

                foreach (Explosion explosion in _explosions)
                {
                    explosion.Draw(_spriteBatch);
                }

                foreach (Satellite satellite in _enemies)
                {
                    satellite.Draw(_spriteBatch);
                }

                _score.Draw(_spriteBatch);
            }
            else
            {
                _menu.Draw(_spriteBatch);
            }
            _spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 4
0
        /// <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)
        {
            GraphicsDevice.Clear(Color.Black);                                                                                         //sets background to be black
            // TODO: Add your drawing code here
            spriteBatch.Begin(sortMode: SpriteSortMode.Immediate, blendState: BlendState.Additive, transformMatrix: camera.Transform); //transforms everything in the spritebatch by the matrix defined in the camera class, gives the illusion of movement!

            player.Draw(spriteBatch);

            //spriteBatch.DrawString(spriteFont: spriteFont, text: $"{projectiles.Count}", position: new Vector2(player.Position.X + 10, player.Position.Y +10), color: Color.White);

            //loops through all projectiles in a list and draws them; if the projectiles is "Dead" then the projectile is removed from the draw list         Projectiles currently includes: bullets, asteroids
            for (int i = 0; i < projectiles.Count; i++)
            {
                projectiles[i].Draw(spriteBatch);
                if (projectiles[i].Dead)
                {
                    projectiles.RemoveAt(i--);
                }
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Draws the gameplay screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0);

            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            // Draw the starfield
            starField.Draw(spriteBatch);

            // Render Players
            if (networkSession == null)
            {
                players.ForEach(delegate(Player p)
                {
                    p.Draw(spriteBatch);
                });
            }
            else
            {
                foreach (NetworkGamer gamer in networkSession.AllGamers)
                {
                    Player p = gamer.Tag as Player;
                    p.Draw(spriteBatch);
                }
            }

            // Render Asteroids
            asteroidManager.Draw(spriteBatch);

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2);

                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }