Ejemplo n.º 1
0
        public static void LoadTilesFromMap(string name, params TilemapCell[] cells)
        {
            Texture tilemap = Resourcepack.GetResource <Texture>(name);

            if (tilemap != null)
            {
                for (int k = 0; k < cells.Length; k++)
                {
                    TilemapCell cell = cells[k];
                    Texture     tile = new Texture(cell.Width, cell.Height);

                    ImageProcessor.Copy(tilemap, tile, cell.X, cell.Y);

                    Resourcepack.AddAsset(cell.name, tile);
                    Resourcepack.AddAsset(cell.name, new Sprite(tile));
                }
            }
        }
Ejemplo n.º 2
0
    public void OnLoad(object sender)
    {
        InputHandlerInitialize();

        Resourcepack.Loadresources();

        Service.Tiling.LoadTilesFromMap("tilemap",
                                        new TilemapCell("grass", 640, 0, 32, 32),
                                        new TilemapCell("tree", 384, 448, 64, 64),
                                        new TilemapCell("wall", 384, 320, 32, 32),
                                        new TilemapCell("floor", 0, 640, 32, 32));

        map          = new World();
        inputContext = new InputContext();

        var graphics = CreateGraphics();

        Input.Initialize(inputContext);
        GraphicsAPI.Initialize(Width, Height, new System.Runtime.InteropServices.HandleRef(graphics, graphics.GetHdc()));
    }