Beispiel #1
0
 // Constructor to generate grid
 public GridGUI(Grid gridModel, SnakeSettings snakeSettings, bool isAlive)
 {
     RowCount    = snakeSettings.RowCount;
     ColumnCount = snakeSettings.ColumnCount;
     SideLength  = snakeSettings.SideLengthGUI;
     GridWidth   = ColumnCount * SideLength;
     GridHeight  = RowCount * SideLength;
     InitilizeGridGUI(gridModel, isAlive);
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new snake game by using the specified snake level.
 /// </summary>
 /// <param name=""></param>
 public SnakeGame(SnakeLevel snakeLevel)
 {
     Grid          = snakeLevel.Grid.GetCopy();
     snakeSettings = snakeLevel.SnakeSettings;
     MaxScore      = snakeLevel.SnakeSettings.MaxScore;
     // Make snake
     Snake = new Snake(Grid.GetPointOfRandomEmptyField(snakeSettings.RandomNumberGenerator));
     // Make food
     Food      = new Food(Grid.GetPointOfRandomEmptyField(snakeSettings.RandomNumberGenerator));
     foundFood = false;
     // Place objects in grid
     Grid.PlaceSnake(Snake);
     Grid.PlaceFood(Food);
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new snake game by using the specified settings to set up af random grid.
 /// </summary>
 public SnakeGame(SnakeSettings snakeSettings)
 {
     this.snakeSettings = snakeSettings;
     MaxScore           = snakeSettings.MaxScore;
     // Make grid
     Grid = new Grid(snakeSettings.RowCount, snakeSettings.ColumnCount);
     // Make snake
     Snake = new Snake(Grid.GetCentrePoint());
     // Make food
     Food      = new Food(Grid.GetPointOfRandomEmptyField(snakeSettings.RandomNumberGenerator));
     foundFood = false;
     // Place objects in grid
     Grid.PlaceSnake(Snake);
     Grid.PlaceFood(Food);
 }
Beispiel #4
0
 // If grid provided but no snake game
 public SnakeGameGUI(SnakeSettings snakeSettings, Grid grid, int score, bool isAlive)
 {
     IsAlive = isAlive;
     Score   = score;
     GridGUI = new GridGUI(grid, snakeSettings, IsAlive);
 }
Beispiel #5
0
 // If snake game provided
 public SnakeGameGUI(SnakeSettings snakeSettings, SnakeGame snakeGame)
 {
     IsAlive = snakeGame.Snake.IsAlive;
     Score   = snakeGame.Score;
     GridGUI = new GridGUI(snakeGame.Grid, snakeSettings, IsAlive);
 }
Beispiel #6
0
 public SnakeLevel(Grid grid, SnakeSettings snakeSettings)
 {
     Grid          = grid;
     SnakeSettings = snakeSettings;
 }