Example #1
0
  /** Called on game start */
  public void setup() {
    instance = this;
    ground = false;
    isFlyMode = false;
    screenSelected = OptionsScreenEnum.mainScreen;

    LogHelper.init();
    SaveData.initDirectory(this);
    RegistryRegistry.init(this);
    IconHelper.init(this);
    player = new Player(width / 2, 0, this);
    Block.blockInit();

    selectedBlock = GameRegistry.getBlock(selectedBlockID);

    // Frame Stuffs
    size(1280, 720, OPENGL);

    if (frame != null) {
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      URL icon = classLoader.getResource(MainReference.ICON_LOCATION);
      frame.setTitle(MainReference.GAME_NAME);
      frame.setIconImage(getToolkit().getImage(icon));
    }

    frameRate(MainReference.FRAME_RATE);

    addMouseWheelListener(
        new MouseWheelListener() {
          public void mouseWheelMoved(MouseWheelEvent mwe) {
            mouseWheel(mwe.getWheelRotation());
          }
        });
  }
Example #2
0
  /**
   * called when the mouse wheel is used
   *
   * @param delta up (-1) down (1)
   */
  public void mouseWheel(int delta) {
    if (delta == Hardware.mwUP) {
      selectedBlockID++;

      if (selectedBlockID > GameRegistry.getBlockRegistrySize()) selectedBlockID = 1;
    }

    if (delta == Hardware.mwDWN) {
      selectedBlockID--;

      if (selectedBlockID < 1) selectedBlockID = GameRegistry.getBlockRegistrySize();
    }

    selectedBlock = GameRegistry.getBlock(selectedBlockID);
  }