public static void PrintGameBoard() { MGame Game = MGame.Instance; int score = Game.getScore(); int lifes = Game.Snake.Nblife; VGame.Print(GameBoard, Game.Map.Height, Game.Map.Width, score, lifes); }
public static void BuildGameboard() { MGame Game = MGame.Instance; GameBoard = new CellTypes[Game.Map.Width, Game.Map.Height]; int score = Game.getScore(); int lifes = Game.Snake.Nblife; //Print the fruit int fruitX = Game.Fruit.Position.Item1; int fruitY = Game.Fruit.Position.Item2; if (Game.Fruit.GetTypeFruit is FruitLifeUp) { GameBoard[fruitX, fruitY] = CellTypes.FruitLifeUp; } else if (Game.Fruit.GetTypeFruit is FruitSpeedUp) { GameBoard[fruitX, fruitY] = CellTypes.FruitSpeedUp; } else if (Game.Fruit.GetTypeFruit is FruitSpeedDown) { GameBoard[fruitX, fruitY] = CellTypes.FruitSpeedDown; } else { GameBoard[fruitX, fruitY] = CellTypes.Fruit; } //GameBoard[fruitX, fruitY] = CellTypes.Fruit; bool first = true; //Print the snake in the gameboard foreach (var bodypart in Game.Snake.snakebody) { int bodypartX = bodypart.Item1; int bodypartY = bodypart.Item2; // The 1st is the head if (first) { switch (Game.Snake.Orientation) { case SnakeOrientation.Bottom: GameBoard[bodypartX, bodypartY] = CellTypes.SnakeHeadDown; break; case SnakeOrientation.Up: GameBoard[bodypartX, bodypartY] = CellTypes.SnakeHeadUp; break; case SnakeOrientation.Left: GameBoard[bodypartX, bodypartY] = CellTypes.SnakeHeadLeft; break; case SnakeOrientation.Right: GameBoard[bodypartX, bodypartY] = CellTypes.SnakeHeadRight; break; } first = false; } else { GameBoard[bodypartX, bodypartY] = CellTypes.SnakeBody; } } }