Exemplo n.º 1
0
        public void Draw(SpriteBatch spriteBatch, Texture2D texture, Camera camera)
        {
            int startx = (int)MathHelper.Clamp(camera.X * -1 / 24f, 0, MapWidth);
            int endx = 2 + startx + camera.Width / 24;
            int starty = (int)MathHelper.Clamp(camera.Y * -1 / 24f, 0, MapHeight);
            int endy = 2 + starty + camera.Height / 24;

            for (int x = startx; x <= endx; x++)
            {
                for (int y = starty; y <= endy; y++)
                {
                    if (Blocks[x, y] != 0)
                    {
                        byte h = Blocks[x, y];
                        if(Blocks[x,y-1] != 0){ h = 24; }
                        if (Blocks[x, y + 1] == 24 && Blocks[x, y] < 4) { continue; } // little hack

                        spriteBatch.Draw(texture, camera.FromRectangle(new Rectangle(x * 24, y * 24 + 24 - h, 24, h)), new Rectangle(8 * 24, 48, 24, h), Color.White);
                    }
                }
            }
        }