コード例 #1
0
ファイル: GameManager.java プロジェクト: milkers/boatdrift
  /** Constructor */
  public GameManager(MainGameFrame mgf1) {
    // to be able to reach main menu from the game we need to pass it to the actual game manager to
    // know its caller.
    mgf = mgf1;

    setSize(GAME_WIDTH, GAME_HEIGHT);
    addKeyListener(new TAdapter());
    addKeyListener(new PauseAdapter(this));
    setFocusable(true);
    setBackground(Color.CYAN);
    setDoubleBuffered(true);

    // ingame = true;
    pauseFlag = false;
    nextLevelFlag = false;
    directionKeysFlag = mgf.getControls();
    difficultyFlag = mgf.getDifficulty();
    currentLevel = 1;

    // Init game objects
    wind = WindManager.getInstance(); // Initialize singleton WindManager class
    boat = new Boat(0, 20);

    initGame();
    // gamePoint = 0;

    // Init Timer
    timer = new Timer(40, this);
    startTimer();
  }
コード例 #2
0
ファイル: GameManager.java プロジェクト: milkers/boatdrift
  /** Level initialization handled here */
  public void initGame() {
    // First level initializations-burada can da sıfırlanmalı, oyunu restart yapan method bu olmalı
    if (currentLevel == 1) {
      boat.setFlashForward(false); // init bonus state
      boat.replenishUsedNumOfBullets(); // init bonus state
      // boat.setNumOfLives(INITIAL_BOAT_LIFE_AMOUNT);//init bonus state
      boat.setBoatImage(mgf.getBoatColor()); // To set the proper image from the main game frame

      // setDifficultInBoat(mgf.getDifficulty());
      // System.out.println("difffi: " + mgf.getDifficulty());
      if (mgf.getDifficulty()) {
        boat.setNumOfLives(INITIAL_BOAT_LIFE_AMOUNT - 2);
      } else {
        boat.setNumOfLives(INITIAL_BOAT_LIFE_AMOUNT);
      }

      boat.setDirectionKeysOn(mgf.getControls());

      boat.setPosition(0, 20);
      boat.setDirection(0);
      boat.setVisible(true);
      // Game object positions
      buoyPositions =
          new int[][] {
            {250, 500}, {300, 100}, {500, 300}, {450, 125}, {400, 200}, {350, 400}, {200, 250}
          };
      islandPositions =
          new int[][] {
            {50, 175}, // small
            {550, 300}, // medium
            {50, 450} // medium
          };
      islandTypes = new String[] {"small", "medium", "medium"};
      bonusPositions = new int[][] {{60, 350}, {500, 550}};
      gamePoint = 0;
      initBuoys();
      initIslands();
      initBonuses();
      System.out.println("inside init game level-1");
    }
    // other level initializations
    if (currentLevel == 2) {
      initGameLevel2();
    }
    if (currentLevel == 3) {
      initGameLevel3();
    }
  }