Exemple #1
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);
        }