/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here // WorldSquare[,] maze = new WorldSquare[MaxRows, MaxCols]; random = new Random(); player = new AwesomeSquare(); for (int i = 0; i < maxEnemies; i++) { enemies[i] = new EvilSquares(random, maze); } //Initialise the map array for (int row = 0; row < MaxRows; row++) { for (int col = 0; col < MaxCols; col++) { maze[row, col] = new WorldSquare(x, y); x = x + SquareSize; } x = 0; y = y + SquareSize; } //Grid of the map int[,] screen = { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }, { 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1 }, { 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1 }, { 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1 }, { 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1 }, { 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1 }, { 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1 }, { 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }; for (int col = 0; col < MaxCols; col++) { for (int row = 0; row < MaxRows; row++) { if (screen[row, col] == 1) { maze[row, col].containsSquare = true; } } } base.Initialize(); }
public void Die(EvilSquares enemy, int round) { //Collision detection between the player and enemy if (enemy.row == row + 1 && enemy.col == col && enemy.direction == 1 || enemy.row == row - 1 && enemy.col == col && enemy.direction == 3 || enemy.row == row && enemy.col == col + 1 && enemy.direction == 4 || enemy.row == row && enemy.col == col - 1 && enemy.direction == 2) { alive = false; if (lives > 0) { lives--; //Stops decremtnting at 0 if (score > 0) { score = score - 2; } } } }