gameengine.java
来自「Java based Snakes and Ladders game.」· Java 代码 · 共 44 行
JAVA
44 行
// The main game engine, this is where half the work takes placepublic class GameEngine{ // The Variables of the GameEngine private Player player1, player2, currentPlayer; private Dice dice; private int PlayerMove; // The constructor of the GameEngine public GameEngine() { // initialise instance variables player1 = new Player("Player 1"); player2 = new Player("Player 2"); currentPlayer = player1; } // The methods of the GameEngine public int RunGame() { int PlayerMove = dice.PlayerRoll(); changePlayer(); return PlayerMove; } // The methods of the GameEngine public void changePlayer () { // Switch the players if (currentPlayer == player1) { currentPlayer = player2; } else if (currentPlayer == player2) { currentPlayer = player1; } else { // Check to make sure player = Legit System.out.println ("Too Many Players - Something Went Wrong."); System.exit (1); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?