コード例 #1
0
        public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
        {
            Vector2 focusPoint = camera.FocusPoint;
            float   scale      = camera.Scale;

            //Draw background
            parallaxBackground.Draw(spriteBatch, focusPoint, scale, graphicsDevice);

            spriteBatch.End();

            Matrix testMatrix = Matrix.CreateScale(scale);

            testMatrix *= Matrix.CreateTranslation((graphicsDevice.Viewport.Width / 2) - (focusPoint.X * scale), (graphicsDevice.Viewport.Height / 2) - (focusPoint.Y * scale), 0);

            //Test
            spriteBatch.Begin(transformMatrix: testMatrix, samplerState: SamplerState.PointClamp);

            //Draw architecture
            mapArchitecture.Draw(spriteBatch, texturePack);

            //Draw entities
            for (int i = 0; i < entities.Count; i++)
            {
                entities[i].Draw(spriteBatch, this);
            }

            spriteBatch.End();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: dropsonic/artificergame
        /// <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.CornflowerBlue);

            // TODO: Add your drawing code here
            _background.Draw(gameTime);

            base.Draw(gameTime);
        }
コード例 #3
0
        protected override void HandleDraw(SpriteBatch spriteBatch, Rectangle scissorRectangle, DrawSpecifics drawSpecifics)
        {
            spriteBatch.End();
            float focusPointScale = (float)MapStandards.MAP_SIZE / Math.Min(scissorRectangle.Width, scissorRectangle.Height);

            parallaxBackground.Draw(spriteBatch, new Vector2(PastMouseState.Position.X * focusPointScale, PastMouseState.Position.Y * focusPointScale), MapStandards.MAP_SIZE / Math.Min(scissorRectangle.Width, scissorRectangle.Height), gameSession.graphicsDevice);
            spriteBatch.Begin();

            base.HandleDraw(spriteBatch, scissorRectangle, drawSpecifics);
        }
コード例 #4
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin(transformMatrix: Matrix.CreateTranslation(-player.Position.X + cameraOffsetX, 0, 0));

            background.Draw(spriteBatch);

            player.Draw(spriteBatch);

            level.Draw(spriteBatch);

            spriteBatch.End();
        }
コード例 #5
0
        public override void Draw(GameTime gameTime)
        {
            // Draw Background and clouds in seperate Spritebatch call without using View Matrix
            ScreenManager.SpriteBatch.Begin();

            _background.Draw(ScreenManager.SpriteBatch);
            _clouds.Draw(ScreenManager.SpriteBatch);
//             DrawDebug();
//             healthBar.Draw();
            ScreenManager.SpriteBatch.End();

            // Draw all background Objects in seperate Spritebatch call, else Background Objects will appear in front of the towers
            ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
            foreach (StaticObject obj in StaticObject.Objects)
            {
                obj.Draw();
            }
            foreach (AnimatedObject obj in AnimatedObject.Objects)
            {
                obj.Draw();
            }
            // render eyes
            foreach (Eye eye in Eye.Eyes)
            {
                eye.Draw();
            }
            ScreenManager.SpriteBatch.End();



            ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);


            particleManager.Draw();

            // Render breakables Towers before Level part and their cannons before themselves
            foreach (PhysicBreakable breakable in physicBreakables)
            {
                if (breakable.WithCannon == true)
                {
                    breakable.cannon.Draw();
                }
            }

            foreach (PhysicBreakable breakable in physicBreakables)
            {
                breakable.Draw(gameTime);
            }

            // Render Actors
            level.Draw();

            // draw shots
            foreach (Shot shot in Shots)
            {
                shot.Draw();
            }

            // Render Level parts
            foreach (PhysicTexture tex in physicTextures)
            {
                tex.Draw();
            }



            // draw fadeup Texts
            fadeUp.Draw();

            // draw Bridges
            bridge1.Draw(0.3f);
            chainBridge1.Draw(0.2f);
            trap.Draw();

            ScreenManager.SpriteBatch.End();

            // Draw All UI stuff without using View Matrix
            ScreenManager.SpriteBatch.Begin();
            DrawDebug();
            healthBar.Draw();
            ScreenManager.SpriteBatch.End();


            base.Draw(gameTime);
        } // Draw
コード例 #6
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.CornflowerBlue);

            switch (gameState)
            {
            case GameState.Main:
                spriteBatch.Begin();
                spriteBatch.Draw(title, Vector2.Zero, Color.White);
                spriteBatch.End();
                break;

            case GameState.How:
                spriteBatch.Begin();
                spriteBatch.Draw(how, Vector2.Zero, Color.White);
                spriteBatch.End();
                break;

            case GameState.InGame:
                background.Draw();

                spriteBatch.Begin();

                if (beginning[beginning.Length - 1].CollisionRectangle.Right > 0)
                {
                    for (int i = 0; i < beginning.Length; i++)
                    {
                        beginning[i].Draw(spriteBatch);
                    }
                }
                else
                {
                    for (int i = 0; i < Metal.Length; i++)
                    {
                        for (int j = 0; j < Metal[i].Count; j++)
                        {
                            Metal[i][j].Draw(spriteBatch);
                        }
                    }
                }

                for (int i = 0; i < PowerEffects.Count; i++)
                {
                    PowerEffects[i].Draw(spriteBatch);
                }

                for (int i = 0; i < Ast.Count; i++)
                {
                    Ast[i].Draw(spriteBatch);
                }

                for (int i = 0; i < Bullets.Count; i++)
                {
                    Bullets[i].Draw(spriteBatch);
                }

                MCharacter.Draw(spriteBatch);

                spriteBatch.DrawString(verdana, timer, timerPos, Color.White);

                pointString = points.ToString();
                for (int i = pointString.Length; i < 8; i++)     //Put a mask on the points.
                {
                    pointString = "0" + pointString;
                }
                spriteBatch.DrawString(verdana, pointString, pointPos, Color.White);

                spriteBatch.End();
                break;

            case GameState.Lose:
                spriteBatch.Begin();
                spriteBatch.Draw(lose, Vector2.Zero, Color.White);
                //Put the texts in the middle of the screen.
                spriteBatch.DrawString(verdana, pointString, new Vector2(GraphicsDevice.Viewport.Width / 2 - (float)verdana.MeasureString(pointString).Length() / 2, 250), Color.White);
                spriteBatch.DrawString(verdana, timer, new Vector2(GraphicsDevice.Viewport.Width / 2 - (float)verdana.MeasureString(timer).Length() / 2, 300), Color.White);
                spriteBatch.End();
                break;

            default:
                break;
            }

            base.Draw(gameTime);
        }