示例#1
0
  public void update() {
    // System.out.println(gameConfiguration.mute);
    if (gameStatus == -1) {
      return;
    }
    if ((gameStatus == 1) || (gameStatus == 9)) {
      mouseGrabbed = false;
      Main.mouseGrabbed(mouseGrabbed);
      // gameConfiguration.update();
    }

    if (gameStatus == 2) {

      Main.mouseGrabbed(mouseGrabbed);
      if (pause) {
        mouseGrabbed = false;
        return;
      } else {
        mouseGrabbed = true;
      }
      Main.mouseGrabbed(mouseGrabbed);
      gameConfiguration.update();
      script();
      //        prism.update();
      if (blackHole != null) blackHole.update();

      for (GO ob : allObjects) {
        ob.update();
      }
      for (GOPlayer obPlayer : players) {
        blackHole.setGravitationPower(obPlayer);
        obPlayer.update();
        if (restartGame) break;
        else
          for (GOPoint point : obPlayer.path) {
            point.update();
          }
        //            obPlayer.danger = false;
      }
      if (restartGame) {
        Main.restartGame();
        return;
      }
      do {
        somethingWasChanged = false;
        for (GO p : obstacles) {
          p.update();
          if (somethingWasChanged) break;
        }
        for (GOPrism bonus : bonuses) {
          bonus.update();
          if (somethingWasChanged) break;
        }
      } while (somethingWasChanged);
    }
  }
示例#2
0
  public static void saveConfiguration() {
    gameConfiguration.playersAmount = gameConfigurationNew.playersAmount;
    gameConfiguration.isBot = gameConfigurationNew.isBot;
    gameConfiguration.mute = gameConfigurationNew.mute;
    Main.defBotAmount = gameConfiguration.isBot;
    Main.defPlayersAmount = gameConfiguration.playersAmount;
    Main.defMute = gameConfiguration.mute;

    // System.out.println("maindefbot="+Main.defBotAmount+"maindefplayers=="+Main.defPlayersAmount);
    Main.restartGame(true);
  }
示例#3
0
  public void getInput() {
    if (gameStatus != -1) {
      float b = (float) (15f / Main.fps);
      switch (controlMode) {
        case 3:
          if (Keyboard.isKeyDown(Keyboard.KEY_DOWN) && !player.isBot) {
            if (player.y <= 100 * Main.ratio - player.amplitude * 2 - player.sy)
              player.playerYShift += b;
          }
        case 1:
          if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) && !player.isBot) {
            if (player.freak >= player.minFreak) player.freak -= freakChanger;
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && !player.isBot) {
            if (player.freak <= player.maxFreak) player.freak += freakChanger;
          }
          if (player2 != null) {
            if (Keyboard.isKeyDown(Keyboard.KEY_A) && !player2.isBot) {
              if (player2.freak >= player.minFreak) player2.freak -= freakChanger;
            }
            if (Keyboard.isKeyDown(Keyboard.KEY_D) && !player2.isBot) {
              if (player2.freak <= player.maxFreak) player2.freak += freakChanger;
            }
          }
          break;
        case 2:
          if (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !player.isBot) {
            if (player.freak <= player.maxFreak) player.freak += freakChanger;
          }

          if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
            ListWorker.getList();
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_M)) {
            gameConfiguration.mute = true;
            if (Draw.musicIsPlaying(Music.FON1)) Draw.musicStop(Music.FON1);
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_N)) {
            gameConfiguration.mute = false;
            if (!Draw.musicIsPlaying(Music.FON1)) Draw.musicPlay(Music.FON1);
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_0)) {
            mouseGrabbed = true;
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_9)) {
            mouseGrabbed = false;
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_P)) {
            pause = true;
          }
          if (Keyboard.isKeyDown(Keyboard.KEY_O)) {
            pause = false;
          }
          if (player2 != null) {
            if (Keyboard.isKeyDown(Keyboard.KEY_Q) && !player2.isBot) {
              if (player2.freak <= player2.maxFreak) player2.freak += freakChanger;
            }
          }
          break;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_I)) {
        player.immortalityDie = 99999999;
        player.die = false;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_O)) {
        player.immortalityDie = 0;
        player.die = false;
      }
      /*if (Keyboard.isKeyDown(Keyboard.KEY_3)) {
          if (gameStatus == 9)
              restartGame = true;
          gameStatus = 3;
          changedGameStatus = true;
          return;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
          if (gameStatus == 9)
              restartGame = true;
          gameStatus = 1;
          changedGameStatus = true;
          return;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_2)) {
          if (gameStatus == 9)
              restartGame = true;
          gameStatus = 2;
          changedGameStatus = true;

          return;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_0)) {
          if (gameStatus == 9)
              restartGame = true;
          gameStatus = 0;
          changedGameStatus = true;
          return;
      }
      if (Keyboard.isKeyDown(Keyboard.KEY_4)) {
          if (gameStatus == 9)
              restartGame = true;
          gameStatus = 4;
          changedGameStatus = true;
          return;
      } */
    }
    lastKeyDownTime++;

    if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
      if (lastKeyDownTime > 10) {
        lastKeyDownTime = 0;
        changedGameStatus = true;
        if (gameStatus == 9) {
          restartGame = true;
          gameStatus = 0;
          changedGameStatus = true;
        } else {
          if (gameStatus == 2) {
            gameStatus = 1;
          } else {
            if (gameStatus == 1) {
              gameStatus = 2;
            } else {
              if (gameStatus == 0) {
                changedGameStatus = false;
              } else {
                gameStatus = 0;
              }
            }
          }
        }
      }
    }

    if (Mouse.isButtonDown(0)) {
      if (lastKeyDownTime > 10) {
        lastKeyDownTime = 0;
        switch (checkButtonIsOver()) {
          case 1:
            switch (gameStatus) {
              case (-1):
                gameStatus = 0;

                break;

              case 0:
                gameStatus = 2;
                changedGameStatus = true;
                Main.restartGame();

                break;
              case 1:
                gameStatus = 2;
                changedGameStatus = true;
                break;
              case 3:
                if (pg > 1) {
                  pg--;
                }
                //  getPreviousTopList();
                break;
              case 4:
                setMultiplayer();
                break;
              case 9:
                saveScore();
                gameStatus = 10;
                changedGameStatus = true;
                break;

              case 10:
                gameStatus = 2;

                Main.restartGame();
                break;
            }

            break;
          case 2:
            switch (gameStatus) {
              case 0:
                gameStatus = 3; // TOP SCORES
                changedGameStatus = true;
                break;
              case 1:
                gameStatus = 2;

                Main.restartGame();
                break;
              case 3:
                if (pg < maxPg) {
                  pg++;
                }
                //  getNextTopList();
                break;
              case 4:
                setBot();
                break;
              case 9:
                gameStatus = 10;

                break;

              case 10:
                gameStatus = 0;

                changedGameStatus = true;
                break;
            }
            changedGameStatus = true;
            break;
          case 3:
            switch (gameStatus) {
              case 0:
                gameStatus = 4; // Settings
                createNewConfiguration();
                changedGameStatus = true;
                break;
              case 1:
                gameStatus = 0;
                changedGameStatus = true;
                break;
              case 3:
                gameStatus = 0;
                changedGameStatus = true;
                break;
              case 4:
                setAudio();
                break;
            }

            break;
          case 4:
            switch (gameStatus) {
              case 0:
                exit();
                break;
              case 4:

                //   setPreviousMusicGenre();
                break;
            }
            break;
          case 5:
            if (gameStatus == 4)

              //  setNextMusicGenre();
              break;
          case 6:
            if (gameStatus == 4) gameStatus = 0;
            changedGameStatus = true;
            if (changedSettings == true) {
              changedSettings = false;
              saveConfiguration();
              gameConfigurationNew = null;
            }
            break;
          case 7:
            if (gameStatus == 4) gameStatus = 0;
            changedGameStatus = true;
            if (changedSettings == true) {
              changedSettings = false;
              gameConfigurationNew = null;
            }

            break;

          default:
            /*
            if (gameStatus == 9) {
                restartGame = true;
                gameStatus = 2;
                //changedGameStatus = true;

            }*/
            break;
        }
      }
    }

    if ((gameStatus == -1) || (gameStatus == 9)) {

      while (Keyboard.next()) {

        // System.out.println(playerName);

        char x = Keyboard.getEventCharacter();

        // if ((int)(x) == 42) {
        //     continue;
        //  }

        if ((int) (x) == 0) continue;

        if ((int) (x) == 32) continue;

        if ((int) (x) == 13) {
          gameStatus = 0;
          break;
        }

        if ((int) (x) == 8) {
          if (playerNamelenght > 0) {
            playerName.deleteCharAt(playerNamelenght - 1);
            playerNamelenght--;
          }
          continue;
        }

        // playerName = Keyboard.getKeyName(x);
        // playerNameChars[playerNamelenght] = Keyboard.get
        if (playerNamelenght < 15) {
          playerName.append(x);
          playerNamelenght++;
        }

        // System.out.println(playerName);

      }
    }
  }