コード例 #1
0
ファイル: JavaGame.java プロジェクト: ju57u5/JavaGame
  /** Setzt alle Spielparameter zurück und verteilt die Spieler entlang der Main-Ebene */
  public void restartGame() {
    for (int c = 1; c < player.length; c++) {
      if (player[c] != null) {
        player[c].x = (int) (Math.random() * (ebenen[0][1] - ebenen[0][0]) + ebenen[0][0]);
        player[c].y = 0;
        player[c].health = 100;
        player[c].jumpheigth = 200;
        player[c].speed = 5;
        player[c].sperrzeit = 40;
        player[c].freezeControls = false;
        gamerunner.neu = false;
        gamerunner.schonneu = true;
        player[c].amstartwarten = 42;
        player[c].perkzählerjump = -1;
        player[c].perkzählerrun = -1;
        player[c].perkzählershoot = -1;
        player[c].boomRight = 0;
        player[c].boomUp = 0;
        player[c].boomLeft = 0;
        gamerunner.wellenModus.wAnzeige = -1;
        gamerunner.wellenModus.wNeu = false;
        gamerunner.wellenModus.nNeu = false;
        gamerunner.storyModus.amanfang = true;
        gamerunner.wellenModus.amanfang = true;
      } // end of if
    } // end of for

    for (int c = 0; c < gamerunner.shot.length; c++) {
      gamerunner.shot[c] = null;
      DamageLogig.shot[c] = null;
    } // end of for
    DamageLogig.counter = 0;
  }
コード例 #2
0
ファイル: JavaGame.java プロジェクト: ju57u5/JavaGame
  public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ESCAPE && gamerunner.running) {

      Graphics gr = this.getGraphics();
      gr.setFont(new Font("TimesRoman", Font.PLAIN, 40));
      gr.drawString("PAUSE", (int) this.getWidth() / 2, this.getHeight() / 2);
      if (!online) {
        gamerunner.running = false;
      }
      if (soundan) {} // end of if
      Menu menu = new Menu(this);
      // volume.setValue(vol);
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      gamerunner.running = true;
      if (soundan) {} // end of if
    } // end of if-else
    else if (e.getKeyCode() == KeyEvent.VK_R && !online) {
      restartGame();
    } else if (e.getKeyCode() == KeyEvent.VK_F11) {
      dispose();
      setUndecorated(true);
      String[] arguments = {"fullscreen"};
      new JavaGame(arguments);
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER && online) {
      String message =
          JOptionPane.showInputDialog(null, "Chat", "Nachricht", JOptionPane.PLAIN_MESSAGE);
      try {
        if (!message.isEmpty()) {
          client.sendNewChatMessage(player[client.id].name, message);
        }
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }