/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
public Grid(Game1 game, String layoutFile, int gridHeight, int gridWidth) { this.gridHeight = gridHeight; this.gridWidth = gridWidth; //Load out the text file into a string sr = new StreamReader(layoutFile); strLayout = sr.ReadToEnd(); sr.Close(); //Get number of columns sr = new StreamReader(layoutFile); numCellsWide = sr.ReadLine().Length; sr.Close(); cellWidth = this.gridWidth / numCellsWide; //Get number of rows numCellsHigh = strLayout.Length / numCellsWide; cellHeight = this.gridHeight / numCellsHigh; //Create your grid array grid = new Block[numCellsHigh, numCellsWide]; //Initialize your grid this.Init(game); }
public Stone(Game1 game, Grid grid, String image, int x, int y) : base(game, grid, image, x, y) { }
private void Init(Game1 game) { int count = 0; for (int i = 0; i < numCellsHigh; i++) { for (int j = 0; j < numCellsWide; j++) { while(strLayout[count] == '\r' || strLayout[count] == '\n') { count++; } switch (strLayout[count]) { //Enter your block symbols here case '-': grid[i, j] = new Stone(game, this, "Stone", j, i); count++; break; default: grid[i, j] = null; count++; break; } } } }
public Block(Game1 game, Grid grid, String image, int x, int y) { texture = game.Content.Load<Texture2D>(image); position = grid.GetPosition(x, y); }