Beispiel #1
0
        public void render(TileMap map)
        {
            MapLayer entLay = getLayer(entityLayer);

            entLay.Begin();
            {
                map.Draw(entLay);
            }
            entLay.End();
        }
Beispiel #2
0
        public void renderMap(int layer)
        {
            MapLayer lay = getLayer(layer);

            if (lay is MapLayer && lay.Map != null)
            {
                TileMap map    = lay.Map;
                Vector2 scroll = new Vector2(lay.XScroll, lay.YScroll);//Vector2.Transform(new Vector2(mapLay.XScroll, mapLay.YScroll), Matrix.Invert(world.Game.Resolution.Projection));

                int w = map.Width * Tile.STANDARD_GTILE_WIDTH, h = map.Height * Tile.STANDARD_GTILE_HEIGHT;
                int bx = (int)(world.WorldCamera.Bounds.X * lay.XSpeed - scroll.X), by = (int)(world.WorldCamera.Bounds.Y * lay.YSpeed - scroll.Y),
                    rig = (int)(bx + world.WorldCamera.Bounds.Width), bot = (int)(by + world.WorldCamera.Bounds.Height);
                int startX = bx / w - 1, startY = by / h - 1,
                    endX = rig / w + 1, endY = bot / h + 1;

                lay.Begin();
                {
                    if (lay.WidthWrap && lay.HeightWrap)
                    {
                        for (int x = startX; x < endX; x++)
                        {
                            for (int y = startY; y < endY; y++)
                            {
                                map.Draw(lay, x, y);
                            }
                        }
                    }
                    else if (lay.WidthWrap)
                    {
                        for (int x = startX; x < endX; x++)
                        {
                            map.Draw(lay, x, 0);
                        }
                    }
                    else if (lay.HeightWrap)
                    {
                        for (int y = startY; y < endY; y++)
                        {
                            map.Draw(lay, 0, y);
                        }
                    }
                    else
                    {
                        map.Draw(lay);
                    }
                }
                lay.End();
            }
        }
Beispiel #3
0
        public void render(TileMap map, int layer)
        {
            MapLayer lay = getLayer(layer);

            int w = map.Width * Tile.STANDARD_GTILE_WIDTH, h = map.Height * Tile.STANDARD_GTILE_HEIGHT;
            int bx = (int)(world.WorldCamera.Bounds.X * lay.XSpeed), by = (int)(world.WorldCamera.Bounds.Y * lay.YSpeed),
                rig = bx + world.WorldCamera.Bounds.Width, bot = by + world.WorldCamera.Bounds.Height;
            int startX = bx / w - 1, startY = by / h - 1,
                endX = rig / w + 1, endY = bot / h + 1;

            lay.Begin();
            {
                if (lay.WidthWrap && lay.HeightWrap)
                {
                    for (int x = startX; x < endX; x++)
                    {
                        for (int y = startY; y < endY; y++)
                        {
                            map.Draw(lay, x, y);
                        }
                    }
                }
                else if (lay.WidthWrap)
                {
                    for (int x = startX; x < endX; x++)
                    {
                        map.Draw(lay, x, 0);
                    }
                }
                else if (lay.HeightWrap)
                {
                    for (int y = startY; y < endY; y++)
                    {
                        map.Draw(lay, 0, y);
                    }
                }
                else
                {
                    map.Draw(lay);
                }
            }
            lay.End();
        }