private void CreateLevel() { StreamReader file = new StreamReader("level.txt"); while (!file.EndOfStream) level_data.Add(file.ReadLine()); file.Close(); for (int i = 0; i < level_data.Count; i++) tile_Y += 1; for (int j = 0; j < level_data[1].Length; j++) tile_X += 1; level = new Tile[tile_Y, tile_X]; for (int i = 0; i < level_data.Count; i++) { for (int j = 0; j < level_data[i].Length; j++) { if (level_data[i][j] == 'x') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 0, 16, 16)); } else if (level_data[i][j] == 'f') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); } else if (level_data[i][j] == 'r' || level_data[i][j] == 'm' || level_data[i][j] == 'b' || level_data[i][j] == 'o') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); Character g = new Ghost(character_sheet, new Vector2(j * 16, i * 16), level_data); ghosts.Add(g); } else if (level_data[i][j] == 'p') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); pacman_startpos = new Vector2(j * 16, i * 16); pacman = new Pacman(character_sheet, new Vector2(j * 16, i * 16), level_data, pacman_startpos); } else if (level_data[i][j] == 'e') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 16, 16, 16)); } } } }