コード例 #1
0
 internal void DrawDebugData()
 {
     if (Scene.GameCore.DebugActive && Scene.ExistsEntities(_ => MatchActiveEntitiesAndComponents(_)))
     {
         _debugView.RenderDebugData(Scene.Camera2D.Projection, Scene.Camera2D.View);
     }
 }
コード例 #2
0
        public override void Draw()
        {
            base.Draw();

            spriteBatch.Begin();
            spriteBatch.DrawString(gameFont, _eggCounterString, new Vector2(10.0f, 10.0f), Color.White);
            spriteBatch.End();

            DebugView.RenderDebugData(ref projection);
        }
コード例 #3
0
 public override void Draw(GameTime gameTime)
 {
     if (RenderDebug)
     {
         if (_flagsChanged)
         {
             DebugView.Flags = _flags;
             _flagsChanged   = false;
         }
         DebugView.RenderDebugData(Camera.Projection, Camera.View);
     }
     base.Draw(gameTime);
 }
コード例 #4
0
        public override void DrawDebugView(GameTime gameTime, ref Matrix projection, ref Matrix view)
        {
            base.DrawDebugView(gameTime, ref projection, ref view);

            var worldMtx = Matrix.CreateTranslation(-34, 0, 0);

            debugView2.RenderDebugData(ref projection, ref view, ref worldMtx);

            worldMtx = Matrix.CreateTranslation(0, 20, 0);
            debugView3.RenderDebugData(ref projection, ref view, ref worldMtx);

            worldMtx = Matrix.CreateTranslation(-34, 20, 0);
            debugView4.RenderDebugData(ref projection, ref view, ref worldMtx);
        }
コード例 #5
0
        public void Draw(SpriteBatch sb, SpriteFont font)
        {
            var projection = Matrix.CreateOrthographicOffCenter(0f, ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Width), ConvertUnits.ToSimUnits(sb.GraphicsDevice.Viewport.Height), 0f, 0f, 1f);

            _debugView.RenderDebugData(projection, camera.getScaledViewMatrix());


            var projection2 = Matrix.CreateOrthographicOffCenter(0f, sb.GraphicsDevice.Viewport.Width, sb.GraphicsDevice.Viewport.Height, 0f, 0f, 1f);

            _debugView.BeginCustomDraw(projection2, camera.getViewMatrix());

            foreach (var ray in player.controller.castList)
            {
                _debugView.DrawSegment(ray.from, ray.to, Color.Blue);
            }

            foreach (var p in platformList)
            {
                foreach (var ray in p.controller.castList)
                {
                    _debugView.DrawSegment(ray.from, ray.to, Color.White);
                }
            }


            var areaPoints = new Vector2[] {
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.top)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.right, camera.focusArea.bottom)),
                ConvertUnits.ToDisplayUnits(new Vector2(camera.focusArea.left, camera.focusArea.bottom))
            };

            _debugView.DrawSolidPolygon(areaPoints, 4, Color.Red);

            _debugView.DrawPoint(ConvertUnits.ToDisplayUnits(camera.focusPosition), 3, Color.White);

            _debugView.DrawPoint(camera.Position, 3, Color.Pink);

            var cameraBounds = new Vector2[] {
                new Vector2(camera.Bounds.Left, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Top),
                new Vector2(camera.Bounds.Right, camera.Bounds.Bottom),
                new Vector2(camera.Bounds.Left, camera.Bounds.Bottom)
            };

            _debugView.DrawPolygon(cameraBounds, 4, Color.Green);

            _debugView.EndCustomDraw();
        }
コード例 #6
0
ファイル: PhysicsDemoScreen.cs プロジェクト: lab132/owlicity
        public override void Draw(GameTime gameTime)
        {
            Matrix projection = Camera.SimProjection;
            Matrix view       = Camera.SimView;

            if (RenderDebug)
            {
                if (_flagsChanged)
                {
                    DebugView.Flags = _flags;
                    _flagsChanged   = false;
                }
                DebugView.RenderDebugData(ref projection, ref view);
            }
            base.Draw(gameTime);
        }
コード例 #7
0
        /// <summary>
        /// Renders all thge objects, and debug information
        /// </summary>
        /// <param name="renderer"></param>
        internal void OnDraw(QSpriteRenderer renderer)
        {
            renderer.Begin();
            Entities.SpriteObjects.For(s => s.OnDrawSprite(renderer));
            renderer.End();
            //normally ends here, debug renders here, laggy af
            if (Debug.DebugLevel < 2)
            {
                return;
            }
            var    c = Camera.Bounds;
            Matrix a = Matrix.CreateOrthographicOffCenter(c.Left.ToSim(), c.Right.ToSim(),
                                                          c.Bottom.ToSim(), c.Top.ToSim(), 0, 1);

            DebugView.RenderDebugData(ref a);
        }
コード例 #8
0
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.BatchEffect.View       = _view;
            ScreenManager.BatchEffect.Projection = _proj;
            ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, RasterizerState.CullNone, ScreenManager.BatchEffect);
            _agent.Draw();
            _circles.Draw();
            _rectangles.Draw();
            _stars.Draw();
            _gears.Draw();
            ScreenManager.SpriteBatch.End();
            _border.Draw();


            //base.Draw(gameTime);
            DebugView.RenderDebugData(_proj, _view);
        }
コード例 #9
0
        public void DrawDebug(SpriteBatch batch, Camera camera)
        {
            if (!FarseerEnabled)
            {
                return;
            }
            //Matrix projection = camera.Matrix;
            //Matrix view = camera.Matrix;
            //Matrix projection = camera.GetMatrix(DebugShapes.Parallax);
            Matrix projection = Matrix.CreateOrthographicOffCenter(camera.BoundingRect.Left, camera.BoundingRect.Right,
                                                                   camera.BoundingRect.Bottom, camera.BoundingRect.Top, 0, 1);

            Matrix view = camera.GetMatrix(Vector3.One);

            DebugView.RenderDebugData(ref projection);

            //DebugView.RenderDebugData(ref projection, ref view);
        }
コード例 #10
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(bgColor);

            var vp = GraphicsDevice.Viewport;

            //The following two lines worked before 11/8/18, when I decided to start messing with the camera
            //        _spriteBatchEffect.View = Matrix.CreateLookAt(cameraPosition, cameraPosition + Vector3.Forward, Vector3.Up);
            //      _spriteBatchEffect.Projection = Matrix.CreateOrthographic(Viewport.Width, -Viewport.Height , 0f, 1f);
            //_spriteBatchEffect.Projection = Matrix.CreateOrthographic(cameraViewWidth, cameraViewWidth / vp.AspectRatio, 0f, -1f);

            Vector3 newV = new Vector3(Camera.center.X, cameraPosition.Y, 0);

            if (canYCameraMove)
            {
                newV = new Vector3(cameraPosition.X, Camera.center.Y, 0);
            }
            _spriteBatchEffect.View       = Matrix.CreateLookAt(newV, newV + Vector3.Forward, Vector3.Up);
            _spriteBatchEffect.Projection = Matrix.CreateOrthographic(Viewport.Width, -Viewport.Height, 0f, 1f);


            // TODO: Add your drawing code here

            base.Draw(gameTime);


            // in Draw()
            GraphicsDevice.Clear(bgColor);


            //restore this to spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend);
            spriteBatch.Begin(SpriteSortMode.Texture, BlendState.AlphaBlend, null, null, null, null, camera.transform);
            //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullClockwise, _spriteBatchEffect);

            EntityManager.Draw(spriteBatch);
            BackgroundManager.Draw(spriteBatch);
            spriteBatch.End();
            if (isDebugMode)
            {
                debugView.RenderDebugData(_spriteBatchEffect.Projection, _spriteBatchEffect.View, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, 0.8f);
            }
            ui.Draw(spriteBatch);
        }
コード例 #11
0
ファイル: Test.cs プロジェクト: andrew-sidereal/AetherX
        public virtual void DrawDebugView(float elapsedSeconds, ref Matrix projection, ref Matrix view)
        {
            if (this.World.HibernationEnabled)
            {
                this.DebugView.BeginCustomDraw(projection, view);

                // show the user where the independent active area would be moved provided right mouse button is clicked
                Color independentActiveAreaColor = ColorHelper.FromPercentages(0.30f, 0.10f, 0.10f);
                AABB  newActiveArea = new AABB(this.MouseWorldPosition, this.IndependentActiveAreaRadius * 2, this.IndependentActiveAreaRadius * 2);
                this.DebugView.DrawAABB(ref newActiveArea, independentActiveAreaColor);

                bool renderActiveAreaBodyCount = false; // NOTE: flip this to true to see the number of bodies currently within each active area for debug purposes.
                if (renderActiveAreaBodyCount)
                {
                    foreach (var activeArea in this.World.HibernationManager.ActiveAreas)
                    {
                        // render number of bodies within each active area
                        Vector2 position = new Vector2(activeArea.AABB.LowerBound.X, activeArea.AABB.UpperBound.Y);
                        position = GameInstance.ConvertWorldToScreen(position);
                        DebugView.DrawString((int)position.X, (int)position.Y - 5, "Contains " + activeArea.AreaBodies.Count().ToString());
                    }
                }

                this.DebugView.EndCustomDraw();
            }

            bool renderBodyIds = false; // NOTE: flip this to true to see body IDs for debug purposes.

            if (renderBodyIds)
            {
                foreach (var body in this.World.BodyList)
                {
                    // render body ID
                    var position = GameInstance.ConvertWorldToScreen(body.Position);
                    DebugView.DrawString((int)position.X - 5, (int)position.Y - 5, "Id " + body.Id.ToString());
                }
            }

            DebugView.RenderDebugData(ref projection, ref view);
        }
コード例 #12
0
ファイル: Game1.cs プロジェクト: nsteele36/SPACEWALK
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            //BACK GROUND
            spriteBatch.Begin();
            scrolling1.Draw(spriteBatch);
            scrolling2.Draw(spriteBatch);
            spriteBatch.End();

            //CREATE VIEW POINT FROM CAMERA
            var vp = GraphicsDevice.Viewport;

            _spriteBatchEffect.View       = Matrix.CreateLookAt(_cameraPosition, _cameraPosition + Vector3.Forward, Vector3.Up);
            _spriteBatchEffect.Projection = Matrix.CreateOrthographic(cameraViewWidth, cameraViewWidth / vp.AspectRatio, 0f, -1f);

            //BEGIN DRAWING SPRITES FROM CAMERA VIEW
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, RasterizerState.CullClockwise, _spriteBatchEffect);

            //DRAW PLAYER
            spriteBatch.Draw(playerTexture, _player.getBody().Position, null, Color.White, _player.getBody().Rotation, _player.getTextureOrigin(), _player.getBodySize() / _player.getTextureSize(), SpriteEffects.FlipVertically, 0f);

            //DRAW ROAD
            RoadManager.Draw(spriteBatch, _road1, _road2, _road3);

            //DRAW OBSTACLES
            ObstacleManagerJ.Draw(spriteBatch, _jumpObstacles1, _jumpObstacles2, _jumpObstacles3);
            ObstacleManagerC.Draw(spriteBatch, _crouchObstacles1, _crouchObstacles2, _crouchObstacles3);

            //END
            spriteBatch.End();

            //UI
            spriteBatch.Begin();

            spriteBatch.DrawString(font, "Score: " + (int)_player.getScore(), new Vector2(50, 80), Color.White);

            if (!_player.getIsMoving() && !_player.getIsCrashed())
            {
                spriteBatch.DrawString(font, "                         CONTROLS\n1. Press blue puck to jump.\n2. Press yellow puck to crouch.\n3.Press both pucks at the same time to start", new Vector2(500, 750 / 2), Color.Yellow);
            }

            if (_player.getIsOutOfBounds())
            {
                spriteBatch.DrawString(font, "                        OUT OF BOUNDS!\n\n\n\n\n\n\nPress both pucks at the same time to restart", new Vector2(500, 750 / 2), Color.Red);
            }
            else if (_player.getIsCrashed())
            {
                spriteBatch.DrawString(font, "                              CRASHED!\n\n\n\n\n\n\nPress both pucks at the same time to restart", new Vector2(500, 750 / 2), Color.Red);
            }

            if (_player.getIsPassed())
            {
                spriteBatch.DrawString(font, "Enemy Passed! +500", new Vector2(50, 20), Color.Yellow);
            }

            if (_player.getLevelUp() && _player.getLevelUptimer() < (float)gameTime.TotalGameTime.TotalSeconds)
            {
                spriteBatch.DrawString(font, "     LEVEL UP!\nSpeed Increased", new Vector2(800, 40), Color.Yellow);
            }

            spriteBatch.End();

            //DEBUGGER
            if (debuggerSwitch)
            {
                debugView.RenderDebugData(_spriteBatchEffect.Projection, _spriteBatchEffect.View, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, 0.8f);
                spriteBatch.Begin();

                spriteBatch.DrawString(font, "Time: " + (int)totalTime + " seconds", new Vector2(50, 60), Color.White);
                spriteBatch.DrawString(font, "Obstacles Passed: " + _player.getObstaclesPassed(), new Vector2(50, 80), Color.White);
                if (_player.getCurrentRoad() == 1)
                {
                    spriteBatch.DrawString(font, "Current Road: MIDDLE (road" + _player.getCurrentRoad() + ")", new Vector2(50, 220), Color.White);
                }
                else if (_player.getCurrentRoad() == 2)
                {
                    spriteBatch.DrawString(font, "Current Road: TOP (road" + _player.getCurrentRoad() + ")", new Vector2(50, 220), Color.White);
                }
                else if (_player.getCurrentRoad() == 3)
                {
                    spriteBatch.DrawString(font, "Current Road: BOTTOM (road" + _player.getCurrentRoad() + ")", new Vector2(50, 220), Color.White);
                }
                else if (_player.getCurrentRoad() == 4)
                {
                    spriteBatch.DrawString(font, "Current Road: OUT OF BOUNDS", new Vector2(50, 220), Color.White);
                }

                if (_player.getIsOnRoad())
                {
                    spriteBatch.DrawString(font, "ON ROAD", new Vector2(50, 240), Color.White);
                }
                else
                {
                    spriteBatch.DrawString(font, "OFF ROAD", new Vector2(50, 240), Color.White);
                }
                spriteBatch.DrawString(font, "Player Pos: " + _player.getBody().Position, new Vector2(50, 260), Color.White);
                spriteBatch.End();
            }
            base.Draw(gameTime);
        }
コード例 #13
0
 public override void Draw(GameTime gameTime)
 {
     DebugView.RenderDebugData(Camera.Projection, Camera.View);
     base.Draw(gameTime);
 }
コード例 #14
0
 /// <summary>
 /// Vykreslení jednoho snímku scény.
 /// </summary>
 public virtual void Draw()
 {
     DebugView.RenderDebugData(Demo.Camera3D.Projection, Demo.Camera3D.View);
 }
コード例 #15
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (!_reloaded)
            {
                Game.Lighting.Refresh();
                _reloaded = true;
            }

            // Draw background
            Game.GraphicsDevice.SetRenderTarget(BackgroundTexture);
            DrawComponentLayer(spriteBatch, -1);

            // Draw foreground
            Game.GraphicsDevice.SetRenderTarget(ForegroundTexture);

            // Prepare lighting
            Game.Lighting.Debug = DebugView.Enabled;
            Lighting.BeginDraw(Camera.ViewMatrix);
            Game.GraphicsDevice.Clear(Color.Transparent);

            // Ground rendering
            DrawComponentLayer(spriteBatch, 0);

            // Draw weather
            // TODO: better layer numbering
            DrawComponentLayer(spriteBatch, 10);

            // Draw entities and particles
            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Camera != null ? Camera.ViewMatrix : Matrix.Identity);
            Entities.ForEach(e => e.Draw(spriteBatch));
            Particles.ForEach(p => p.Draw(spriteBatch));
            spriteBatch.End();

            // Ground rendering
            DrawComponentLayer(spriteBatch, 1);
            Lighting.Draw();

            // Draw to screen
            Game.GraphicsDevice.SetRenderTarget(null);
            Game.GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
            spriteBatch.Draw(BackgroundTexture, Vector2.Zero, null, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            spriteBatch.Draw(ForegroundTexture, Vector2.Zero, null, Color.White, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 1f);
            spriteBatch.End();

            // Render debug physics view
            if (DebugView.Enabled)
            {
                spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, Camera != null ? Camera.ViewMatrix : Matrix.Identity);
                foreach (Entity ent in Entities)
                {
                    var body = ent.GetComponent <BodyComponent>();
                    if (body != null)
                    {
                        spriteBatch.DrawRectangle(body.BoundingBox, new Color(255, 0, 0, 80), 0);
                    }
                }
                spriteBatch.End();
                Matrix proj = Matrix.CreateOrthographic(Game.Resolution.X / 64f, -Game.Resolution.Y / 64f, 0, 1);
                Matrix view = (Camera != null ? Matrix.CreateTranslation(-Camera.Position.X / 64f, -Camera.Position.Y / 64f, 0) : Matrix.Identity) *
                              Matrix.CreateRotationZ(Camera.Rotation) *
                              Matrix.CreateScale(Camera.Zoom);
                lock (Physics)
                    DebugView.RenderDebugData(proj, view);

                StringBuilder text = new StringBuilder();
                var           mpos = Camera.ToWorldSpace(Game.Input.GetPointerInput(0).Position);
                text.AppendFormat("Mouse position: {0}, {1}", (int)mpos.X, (int)mpos.Y);
                var font = ContentLoader.Fonts["menu"];
                spriteBatch.Begin();
                spriteBatch.DrawString(font, text, new Vector2(Game.Resolution.X, 0), Color.White, 0, new Vector2(font.MeasureString(text).X, 0), 0.3f, SpriteEffects.None, 1f);
                spriteBatch.End();
            }
        }
コード例 #16
0
ファイル: Test.cs プロジェクト: SjaakAlvarez/Aether.Physics2D
 public virtual void DrawDebugView(GameTime gameTime, ref Matrix projection, ref Matrix view)
 {
     DebugView.RenderDebugData(ref projection, ref view);
 }
コード例 #17
0
 public void DrawDebugView(Camera2D camera)
 {
     DebugView.RenderDebugData(ref camera.SimProjection, ref camera.SimView);
 }
コード例 #18
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            GraphicsDevice.Clear(Color.Black);

            //Update lights and camera
            Camera.main.Update();
            Lighting.Update();

            //Update graphics state
            GraphicsDevice.BlendState        = BlendState.Opaque;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.RasterizerState   = new RasterizerState()
            {
                CullMode = CullMode.CullClockwiseFace
            };

            //Render shadow map
            GraphicsDevice.SetRenderTarget(Lighting.ShadowMap);
            GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1.0f, 0);
            effect.CurrentTechnique = effect.Techniques["ShadowMap"];

            environment.Render(gameTime, GraphicsDevice, effect);
            player.Render(gameTime, effect);
            trafficManager.RenderTraffic(gameTime, effect);


            //Render scene
            GraphicsDevice.RasterizerState = new RasterizerState()
            {
                CullMode = CullMode.CullCounterClockwiseFace
            };
            GraphicsDevice.SetRenderTarget(null);

            postProcessor.Begin();

            effect.CurrentTechnique = effect.Techniques["ShadowedScene"];
            environment.Render(gameTime, GraphicsDevice, effect);

            player.Render(gameTime, effect);
            trafficManager.RenderTraffic(gameTime, effect);

            postProcessor.End(player.crashed);


            //Render GUI
            spriteBatch.Begin();

            scoreUI.Render(spriteBatch, inTargetLane);
            countdownUI.Render(spriteBatch);
            titleUI.Render(spriteBatch, gameTime);

            if (player.crashed && state != GameState.RESTARTING)
            {
                gameOverUI.Render(spriteBatch, gameTime);
            }

            spriteBatch.End();

            //Render debug
            if (TrafficGame.DEBUG)
            {
                trafficManager.RenderDebug(debugView, Camera.main.View, Camera.main.Projection);
                debugView.RenderDebugData(Camera.main.Projection, Camera.main.View, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, 0.8f);
                spriteBatch.Begin();
                fpsUI.Render(spriteBatch);
                spriteBatch.End();

                //DEBUG: show shadow map
                spriteBatch.Begin(0, BlendState.Opaque, SamplerState.AnisotropicClamp);
                spriteBatch.Draw(Lighting.ShadowMap, new Rectangle(0, GraphicsDevice.Viewport.Height - 256, 256, 256), Color.White);
                spriteBatch.End();
            }
        }