Beispiel #1
0
        protected virtual void DrawDebugData()
        {
            string networkData  = "";
            string graphicsData = "";


            graphicsData = String.Format("fps: {0} ",
                                         Math.Floor(FrameCounter.GetAverageFramerate())
                                         );
            if (Client.IsConnected)
            {
                networkData = String.Format(
                    "ping: {0}ms ent: {1} download {2}KiB upload {3}KiB, avg {4}KiB/s {5}KiB/s",
                    Math.Floor(ping * 1000),
                    World.entities.Count,
                    Math.Floor(Client.DataTotalIn / 1000.0),
                    Math.Floor(Client.DataTotalOut / 1000.0),
                    Math.Floor(Client.DataAverageIn / 100) / 50,
                    Math.Floor(Client.DataAverageOut / 100) / 50
                    );
            }

            SpriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, Camera.ScreenSpaceMatrix);
            TextRenderer.Print(SpriteBatch, networkData, new Vector2(0, 0), Color.White);
            TextRenderer.Print(SpriteBatch, graphicsData, new Vector2(0, 16), Color.White);
            SpriteBatch.End();
        }
        private void DrawHud(GameTime gameTime)
        {
            spriteBatch.Begin();
            float fps = FrameCounter.GetAverageFramerate();

            spriteBatch.DrawString(mDebugFont, "FPS: " + fps.ToString("N0"), new Vector2(10, 10), Color.White);
            string tileDebug = "Tiles Drawn: " + mRenderDebugInfo.numTilesDrawn + " / " + mRenderDebugInfo.numTilesTotal + " ( " + ((float)mRenderDebugInfo.numTilesDrawn / (float)mRenderDebugInfo.numTilesTotal * 100.0f).ToString("N0") + " % )";

            spriteBatch.DrawString(mDebugFont, tileDebug, new Vector2(10, 25), Color.White);
            spriteBatch.End();
        }
Beispiel #3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, screenTransform);



            // draw backgrounds

            for (int x = 0; x < 16; x++)
            {
                for (int y = 0; y < 16; y++)
                {
                    spriteBatch.Draw(backgrounds[(int)background], new Vector2(x * 64, y * 64), Color.White);
                }
            }

            spriteBatch.Draw(playerTexture, player.GetRenderPosition(), Color.White);


            for (int x = 0; x < Definitions.MAP_WIDTH; x++)
            {
                for (int y = 0; y < Definitions.MAP_HEIGHT; y++)
                {
                    int tileid = (int)map.tiles[x, y];
                    //weird temporary gay hack
                    tileid--;

                    if (tileid > 0)
                    {
                        Rectangle quad = tileManager.GetRectangle((byte)tileid);
                        spriteBatch.Draw(terrainTexture, new Vector2(x * Definitions.TILE_SIZE, y * Definitions.TILE_SIZE), quad, Color.White);
                    }
                }
            }


            spriteBatch.DrawString(font, mapname + "\nby " + creator, new Vector2(480, 3), Color.White);

            //spriteBatch.Draw(floorTexture, floor.getRenderPosition());

            double framerate = frameCounter.GetExactFramerate();
            double average   = frameCounter.GetAverageFramerate();

            spriteBatch.DrawString(font, "fps: " + Math.Floor(framerate).ToString() + " avg: " + Math.Floor(average).ToString(), new Vector2(0, 0), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }