public void checkLevelStatus() { if (!humanPlayer.isActive()) { game.playSound(Resources.getSound("explosion")); game.gameOver(); } else if (!computerPlayer.isActive()) { game.playSound(Resources.getSound("explosion")); currentLevel++; currentScore.setStat(currentScore.getStat() + 10); deployLevel(currentLevel); } if (humanPlayer.isPaused()) { humanPlayer.invokePause(); game.togglePauseGame(); } }
@Override public void update(long elapsedTime) { keyboardControl.update(); deployPlayerBlocks(); currentPlayField.update(elapsedTime); computerPlayer.aiUpdate(currentPlayField); checkLevelStatus(); }
public void resetPlayers() { humanPlayer.setLocation(humanPlayerStartingLocation.x, humanPlayerStartingLocation.y); computerPlayer.setLocation(computerPlayerStartingLocation.x, computerPlayerStartingLocation.y); humanPlayer.changeDirection("RIGHT"); computerPlayer.changeDirection("LEFT"); humanPlayer.setActive(true); computerPlayer.setActive(true); blockQueue.clear(); }
public void initializePlayers() { Sprite humanSprite = new Sprite( Resources.getImage("humanPlayer"), humanPlayerStartingLocation.x, humanPlayerStartingLocation.y); Sprite computerSprite = new Sprite( Resources.getImage("computerPlayer"), computerPlayerStartingLocation.x, computerPlayerStartingLocation.y); humanPlayer = new CyclePlayer("humanPlayer", humanSprite); computerPlayer = new CyclePlayer("computerPlayer", computerSprite); resetPlayers(); keyboardControl = new KeyboardControl(humanPlayer, game); keyboardControl = humanPlayer.addPlayerControl( keyboardControl, KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT); }