public static void Initialise() { BBlocks.AddBlock(1, new BBlockTemplate("Water", BBlockType.Solid, new RectangleF(0, 0, AppInfo.TILESIZE, AppInfo.TILESIZE))); BBlocks.AddBlock(2, new BBlockTemplate("Grass", BBlockType.Ground, new RectangleF(AppInfo.TILESIZE, 0, AppInfo.TILESIZE, AppInfo.TILESIZE))); BBlocks.AddBlock(3, new BBlockTemplate("Dirt", BBlockType.Ground, new RectangleF(AppInfo.TILESIZE * 2, 0, AppInfo.TILESIZE, AppInfo.TILESIZE))); BBlocks.AddBlock(4, new BBlockTemplate("Sand", BBlockType.Ground, new RectangleF(AppInfo.TILESIZE * 3, 0, AppInfo.TILESIZE, AppInfo.TILESIZE))); BBlocks.AddBlock(5, new BBlockTemplate("Stone", BBlockType.Ground, new RectangleF(AppInfo.TILESIZE * 4, 0, AppInfo.TILESIZE, AppInfo.TILESIZE))); }
public override void OnLoad(BWindow Window) { base.OnLoad(Window); Camera = new BCamera(Vector2.Zero, 1.0, 0.0); InitialiseTextures(); BBlocks.Initialise(); InitialiseBlocks(); InitialiseLevel(); }
public BLevel(int width, int height) { grid = new BBlock[width, height]; entities = new List <BEntity>(); mapname = "none"; playerStartPos = new Point((int)(width / AppInfo.TILESIZE), (int)(height / AppInfo.TILESIZE)); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (x == 0 || y == 0 || x == width - 1 || y == height - 1) { BBlockTemplate block = BBlocks.GetBlock(1); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } else { BBlockTemplate block = BBlocks.GetBlock(2); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } } } }
public BLevel(string mapname) { try { if (!Directory.Exists("Content/Maps")) { Directory.CreateDirectory("Content/Maps"); } if (!File.Exists($"Content/Maps/{mapname}.ls")) { throw new FileNotFoundException($"No map found with name '{mapname}'."); } var Map = BLevelFile.FromJson(File.ReadAllText($"Content/Maps/{mapname}.ls")); int width = Map.Width; int height = Map.Height; grid = new BBlock[width, height]; entities = new List <BEntity>(); this.mapname = mapname; playerStartPos = new Point(1, 1); int[] Tiles = Map.Layers[0].Data; int x = 0; int y = 0; for (int i = 0; i < Tiles.Length; i++) { BBlockTemplate block = BBlocks.GetBlock(Tiles[i]); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); x++; if (x >= width) { x = 0; y++; } } playerStartPos = new Point(width / 2, height / 2); } catch (Exception e) { Console.WriteLine(e.Message); int width = 20; int height = 20; grid = new BBlock[width, height]; entities = new List <BEntity>(); this.mapname = "none"; playerStartPos = new Point(1, 1); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (x == 0 || y == 0 || x == width - 1 || y == height - 1) { BBlockTemplate block = BBlocks.GetBlock(1); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } else { BBlockTemplate block = BBlocks.GetBlock(2); grid[x, y] = new BBlock(block.Name, block.Type, block.TexturePosition, x, y); } } } } }