Example #1
0
 private void testAndMove(Input input, int delta) {
   xVelocity = 0;
   yVelocity = 0;
   if (input.isKeyDown(Input.KEY_LEFT)) {
     xVelocity--;
   }
   if (input.isKeyDown(Input.KEY_RIGHT)) {
     xVelocity++;
   }
   if (input.isKeyDown(Input.KEY_UP)) {
     yVelocity--;
   }
   if (input.isKeyDown(Input.KEY_DOWN)) {
     yVelocity++;
   }
   double mag = Math.sqrt(xVelocity * xVelocity + yVelocity * yVelocity);
   // make it uniform speed
   xVelocity = (float) (1.0 * SPEED * xVelocity / mag);
   yVelocity = (float) (1.0 * SPEED * yVelocity / mag);
   if (mag != 0) {
     nudge(xVelocity, yVelocity);
   } else {
     xVelocity = 0;
     yVelocity = 0;
   }
 }
Example #2
0
  @Override
  public void update(GameContainer gc, StateBasedGame sb, int delta) {

    float rotation = owner.getRotation();
    float scale = owner.getScale();
    Vector2f position = owner.getPosition();

    Input input = gc.getInput();

    if (input.isKeyDown(Input.KEY_LEFT)) {
      rotation += -0.2f * delta;
    }

    if (input.isKeyDown(Input.KEY_RIGHT)) {
      rotation += 0.2f * delta;
    }

    if (input.isKeyDown(Input.KEY_UP)) {
      float hip = 0.45f * delta;

      position.x += hip * java.lang.Math.sin(java.lang.Math.toRadians(rotation));
      position.y -= hip * java.lang.Math.cos(java.lang.Math.toRadians(rotation));
    }

    owner.setPosition(position);
    owner.setRotation(rotation);
    owner.setScale(scale);
  }
 @Override
 public void update(GameContainer container, GomokuClient game, int delta) throws SlickException {
   Input input = container.getInput();
   if (input.isKeyPressed(Input.KEY_ESCAPE)) {
     exitState();
   }
 }
Example #4
0
 @Override
 public void update(GameContainer container, int arg1) throws SlickException {
   input = container.getInput();
   if (input.isKeyPressed(Input.KEY_ENTER)) {
     GameStart = true;
   }
   if (!player.GameOver && GameStart) {
     invul_frame -= 1;
     trap.update(v);
     for (int x = 0; x < 4; x++) {
       for (int y = 0; y < 3; y++) {
         walls[x][y].update(v);
       }
     }
     input = container.getInput();
     player.update();
     if (input.isKeyPressed(Input.KEY_SPACE)) {
       player.jump();
     }
     if (isCollide(player, trap, invul_frame)) {
       player.HIT();
       ;
       invul_frame = 30;
     }
     if (trap.getX() <= -100) {
       randomTrap();
     }
   }
   input = container.getInput();
   if (player.GameOver && input.isKeyPressed(Input.KEY_R)) {
     GameStart = false;
     container.reinit();
   }
 }
 /** Nothing to update. */
 @Override
 public void update(GameContainer gc, int delta) throws SlickException {
   Input input = gc.getInput();
   if (input.isKeyPressed(Input.KEY_ESCAPE)) {
     System.exit(0);
   }
 }
Example #6
0
 public void listenInput(GameContainer gc, StateBasedGame sbg, int delta) {
   Input input = gc.getInput();
   if (input.isKeyPressed(Input.KEY_DOWN)) {
     cursor = Math.min(cursor + 1, 2);
   } else if (input.isKeyPressed(Input.KEY_UP)) {
     cursor = Math.max(cursor - 1, 0);
   }
   if (cursor == 0 && input.isKeyDown(Input.KEY_RIGHT)) {
     control.changeVolume(delta * 0.5f);
   } else if (cursor == 0 && input.isKeyDown(Input.KEY_LEFT)) {
     control.changeVolume(-delta * 0.5f);
   }
   if (cursor == 1 && input.isKeyDown(Input.KEY_RIGHT)) {
     control.goFullScreen(true);
   } else if (cursor == 1 && input.isKeyDown(Input.KEY_LEFT)) {
     control.goFullScreen(false);
   }
   if (cursor == 2 && input.isKeyDown(Input.KEY_RIGHT)) {
     control.changeBrightness(+5);
   } else if (cursor == 2 && input.isKeyDown(Input.KEY_LEFT)) {
     control.changeBrightness(-5);
   } else if (input.isKeyDown(Input.KEY_ENTER)) {
     ((GameController) gc).changeState("pause");
     //			sbg.enterState(((Game)sbg).prevState);
     ((GameController) gc).changeState(((Game) sbg).prevState);
   }
 }
  /** Initialise the GL context */
  protected void initGL() {
    Log.info("Starting display " + width + "x" + height);
    String extensions = GL11.glGetString(GL11.GL_EXTENSIONS);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    if (input == null) {
      input = new Input(height);
    }
    input.init(height);
    input.removeListener(lastGame);
    input.addListener(game);
    lastGame = game;
  }
  @Override
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    Input input = container.getInput();
    int mouseX = input.getMouseX();
    int mouseY = input.getMouseY();
    boolean startGame = false;
    boolean exitGame = false;

    if ((mouseX >= menuX && mouseX <= menuX + startGameOption.getWidth())
        && (mouseY >= menuY && mouseY <= menuY + startGameOption.getHeight())) {
      startGame = true;
    } else if ((mouseX >= menuX && mouseX <= menuX + exitOption.getWidth())
        && (mouseY >= menuY + 100 && mouseY <= menuY + 100 + exitOption.getHeight())) {
      exitGame = true;
    }

    if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
      if (startGame) {
        game.enterState(RunGame.GAMEPLAYSTATE);
      } else if (exitGame) {
        container.exit();
      }
    }
  }
Example #9
0
 @Override
 public void update(GameContainer container, StateBasedGame game, int delta)
     throws SlickException {
   UI.update(delta);
   MusicController.loopTrackIfEnded(false);
   if (menuState != null) menuState.update(container, delta, input.getMouseX(), input.getMouseY());
 }
Example #10
0
  @Override
  protected void timedEvents(GameContainer gc, StateBasedGame sbg, int delta) {
    Input input = gc.getInput();

    if (input.isKeyDown(Input.KEY_LEFT)) {
      Globals.player.moveLeft();
    }
    if (input.isKeyDown(Input.KEY_RIGHT)) {
      Globals.player.moveRight();
    }
    if ((input.isKeyPressed(Input.KEY_LCONTROL))
        || (input.isKeyPressed(Input.KEY_RCONTROL))
        || (input.isKeyPressed(Input.KEY_UP))
        || (input.isKeyPressed(Input.KEY_SPACE))) {
      Globals.player.jump();
      // soundJump2.play();
    }
    // useful to have longer jumps my maintaining CTRL
    if (!input.isKeyDown(Input.KEY_LCONTROL)
        && !input.isKeyDown(Input.KEY_UP)
        && !input.isKeyDown(Input.KEY_SPACE)) {
      if (Globals.player.jumping()) {
        Globals.player.setVelocity(Globals.player.getVelX(), Globals.player.getVelY() * 0.95f);
      }
    }
  }
 /**
  * Moves the players. If they are AI:s they move by themselves, otherwise the method receives
  * input from the user and moves the player accordingly.
  *
  * @param input An instance of Input to receive input from the user(s).
  */
 private void movePlayers(Input input) {
   if (player1.getClass().getName().equals("Player")) {
     if (input.isKeyDown(Input.KEY_W)) {
       if (player1.getPositionY() > 0) {
         player1.move("up");
       }
     }
     if (input.isKeyDown(Input.KEY_S)) {
       if (player1.getPositionY() + player2.getSizeY() < windowSizeY) {
         player1.move("down");
       }
     }
   } else {
     // The player is an AI
     player1.move(null);
   }
   if (player2.getClass().getName().equals("Player")) {
     if (input.isKeyDown(Input.KEY_UP)) {
       if (player2.getPositionY() > 0) {
         player2.move("up");
       }
     }
     if (input.isKeyDown(Input.KEY_DOWN)) {
       if (player2.getPositionY() + player2.getSizeY() < windowSizeY) {
         player2.move("down");
       }
     }
   } else {
     // The player is an AI
     player2.move(null);
   }
 }
Example #12
0
  /**
   * checks and sets the state of this button.
   *
   * @param input the current input
   * @param butPosX the X position of this button
   * @param butPosY the Y position of this button
   * @param butWidth the width of this button
   * @param butHeight the height of this button
   */
  protected void buttonStateCheck(
      Input input, int butPosX, int butPosY, int butWidth, int butHeight) {
    if (contains(
        input.getMouseX(),
        input.getMouseY(),
        butPosX,
        butPosY,
        butPosX + butWidth,
        butPosY + butHeight)) {
      if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)
          && (getState() == STATE_HOVER || getState() == STATE_PRESSED)) {
        setState(STATE_PRESSED);

        setClicked(true);
      } else {
        if (!input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
          setState(STATE_HOVER);
        } else {
          setState(STATE_IDLE);
        }
      }
    } else if (!(input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && getState() == STATE_PRESSED)) {
      setState(STATE_IDLE);
      setClicked(false);
    }
  }
Example #13
0
  @Override
  public void enter(GameContainer container, StateBasedGame game) throws SlickException {
    UI.enter();
    if (!enterNotification) {
      if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) {
        UI.sendBarNotification("An opsu! update is available.");
        enterNotification = true;
      } else if (Updater.get().justUpdated()) {
        UI.sendBarNotification("opsu! is now up to date!");
        enterNotification = true;
      }
    }

    // reset button hover states if mouse is not currently hovering over the button
    int mouseX = input.getMouseX(), mouseY = input.getMouseY();
    if (!logo.contains(mouseX, mouseY, 0.25f)) logo.resetHover();
    if (!playButton.contains(mouseX, mouseY, 0.25f)) playButton.resetHover();
    if (!optionsButton.contains(mouseX, mouseY, 0.25f)) optionsButton.resetHover();
    if (!exitButton.contains(mouseX, mouseY, 0.25f)) exitButton.resetHover();
    if (!musicPlay.contains(mouseX, mouseY)) musicPlay.resetHover();
    if (!musicPause.contains(mouseX, mouseY)) musicPause.resetHover();
    if (!musicNext.contains(mouseX, mouseY)) musicNext.resetHover();
    if (!musicPrevious.contains(mouseX, mouseY)) musicPrevious.resetHover();
    if (repoButton != null && !repoButton.contains(mouseX, mouseY)) repoButton.resetHover();
    if (!updateButton.contains(mouseX, mouseY)) updateButton.resetHover();
    if (!downloadsButton.contains(mouseX, mouseY)) downloadsButton.resetHover();
  }
Example #14
0
  @Override
  /** Mis à jour à chaque frame */
  public void update(GameContainer container, int delta) throws SlickException {
    particleEngine.update();

    // Un peu de fun
    if (gameEngine.getStatus() != GameStatus.STARTED)
      if (Math.random() < 0.04) particleEngine.pushBlocks();

    // On gère le fenêtrage
    if (input.isKeyDown(Input.KEY_F)) {
      fullscreen = !fullscreen;
      ((AppGameContainer) container).setDisplayMode(800, 600, fullscreen);
    }
    if (input.isKeyDown(Input.KEY_ESCAPE)) {
      container.exit();
    }

    // On économise un peu de CPU ;)
    try {
      Thread.sleep(5);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
Example #15
0
 @Override
 public void update(GameContainer gc, int delta) throws SlickException {
   world.update(gc, null, delta);
   Camera camera = world.getCamera();
   Input input = gc.getInput();
   cursorTorch.setGlobalCenterX(input.getMouseX() + camera.getGlobalX());
   cursorTorch.setGlobalCenterY(input.getMouseY() + camera.getGlobalY());
 }
 @Override
 public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
   if (in.isKeyDown(Input.KEY_ESCAPE)) {
     gc.exit();
   } else if (in.isKeyDown(Input.KEY_ENTER)) {
     sbg.enterState(1, new FadeOutTransition(), new FadeInTransition());
   }
 }
Example #17
0
 /** @see org.newdawn.slick.BasicGame#keyPressed(int, char) */
 @Override
 public void keyPressed(int key, char c) {
   count++;
   if (key == Input.KEY_SPACE) {
     if (input.isKeyRepeatEnabled()) input.disableKeyRepeat();
     else input.enableKeyRepeat();
   }
 }
Example #18
0
  @Override
  public void update(
      final GameContainer container, final StateBasedGame game, final int deltaInMillis)
      throws SlickException {
    final Input input = container.getInput();

    if (input.isKeyPressed(Input.KEY_F1)) {
      container.setPaused(true);
      try {
        container.setFullscreen(!container.isFullscreen());
      } catch (final SlickException e) {

      }
      container.setVSync(true);
      container.setSmoothDeltas(true);
      container.setMaximumLogicUpdateInterval(17);
      container.setPaused(false);
    }

    if (input.isKeyPressed(Input.KEY_ESCAPE)) {
      onExitKey(container, game);
    }

    final Level level = this.getLevel();

    if (level != null) {
      level.handleInput(input);
      level.update(deltaInMillis);
    }

    Player currentPlayer = level.getCurrentPlayer();
    if (currentPlayer != null) {
      PlayerState state = currentPlayer.getState();
      // change player color
      if (input.isKeyPressed(Input.KEY_C)) {
        state.color = state.color << 1;
        if (state.color > StateColor.BLUE) {
          state.color = StateColor.RED;
        }
      }

      // change weapon color
      if (input.isKeyPressed(Input.KEY_X)) {
        state.weaponColor = state.weaponColor << 1;
        if (state.weaponColor > StateColor.BLUE) {
          state.weaponColor = StateColor.RED;
        }
      }
    }

    // Sorgt dafür dass 1. Collisionnen neu berechnet werden, 2. Zeile
    // Den Objekten gesagt wird die Kollision zu behandeln.
    CollisionManager.update();
    level.handleCollisions();
  }
Example #19
0
  public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
    resetSelectionBooleans();

    int x = input.getMouseX(), y = input.getMouseY();
    backgroundX = -419 * x / 528 - 1365;
    backgroundY = -533 * y / 300 - 1365;

    if (x > 455 && x < 600 && y > 260 && y < 300) hovering[0] = true;
    else if (x > 380 && x < 675 && y > 320 && y < 360) hovering[1] = true;
    else if (x > 455 && x < 600 && y > 380 && y < 420) hovering[2] = true;
  }
Example #20
0
 public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
   Input input = gc.getInput();
   if (Mouse.getX() > 89 && Mouse.getX() < 276 && Mouse.getY() > 15 && Mouse.getY() < 69) {
     Instructions = new Image("res/InstructionsMenu.png");
     if (input.isMouseButtonDown(0)) {
       sbg.enterState(0);
     }
   } else {
     Instructions = new Image("res/Instructions.png");
   }
 }
Example #21
0
  /* ****** *
   * Events *
   * ****** */
  @Override
  protected void notTimedEvents(GameContainer gc, StateBasedGame sbg, int delta) {

    if (input.isKeyPressed(Input.KEY_R)) {
      try {
        Globals.returnState = -1;
        enter(gc, sbg);
      } catch (SlickException e) {
        System.err.println("Erreur lors du relancement du jeu");
      }
      return;
    }
    if (input.isKeyPressed(Input.KEY_B)) {
      map.showBounds();
    }
    if (input.isKeyPressed(Input.KEY_ESCAPE)) {
      currentState = States.GAME_OVER;
    }
    if (input.isKeyPressed(Input.KEY_P)) {
      currentState = States.PAUSE;
    }

    /*if (input.isKeyPressed(Input.KEY_F4)) {
    	map.addEntity(new WalkingIA(Conf.IMG_SPRITES_PATH+"mariowalk_big.png", 3, 0, false, 100, 100, 40, 62, 12,new Node(1)));
    }
    if (input.isKeyPressed(Input.KEY_F5)) {
    	Enemy enemy = new Enemy(Conf.IMG_SPRITES_PATH+"mariowalk_big.png", 3, 100, 100, 40, 62, 2);
    	map.addEntity(enemy);
    	//the ennemies do not collide between each other
    	for (int i = 0; i < map.getWorld().getBodies().size(); i++) {
    		if (map.getEntityByBody(map.getWorld().getBodies().get(i)) instanceof Enemy) {
    			enemy.getBody().addExcludedBody(map.getWorld().getBodies().get(i));
    		}
    	}
    }*/
    // determines if the character moves
    Globals.player.setMoving(false);
    if (input.isKeyDown(Input.KEY_LEFT) || input.isKeyDown(Input.KEY_RIGHT)) {
      Globals.player.setMoving(true);
    }
    if (input.isKeyPressed(Input.KEY_F1)) {
      // jouer un son : l'aide
      // TODO
      helpSound.play();
    }
    if (input.isKeyPressed(Input.KEY_F2)) {
      Globals.dialogNextState = Globals.returnState;
      sbg.enterState(
          Songe.DIALOGSTATE, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
    }
    if (input.isKeyPressed(Input.KEY_F3)) {
      voix.stop();
      voix.playShortText("Vous avez " + Globals.score + " points.");
    }
  }
  @Override
  public void update(GameContainer gc, StateBasedGame sbg, int delta) {
    inventoryBoxes.clear();

    int numColumns = (int) (dims.getWidth() / partInterval);

    int startX = (int) (dims.getX() + (dims.getWidth() % partInterval) / 2);
    int startY = (int) dims.getY() + offsetY;

    int x = startX;
    int y = startY;

    for (int i = 0; i < parts.size(); i++) {
      ShipPart tempPart = parts.get(i);
      Rectangle rect =
          new Rectangle(
              x + (partInterval - partSize) / 2,
              y + (partInterval - partSize) / 2,
              partSize,
              partSize);
      inventoryBoxes.add(new ShipPartBox(tempPart, rect));
      if (i % numColumns == numColumns - 1) {
        x = startX;
        y += partInterval;
      } else {
        x += partInterval;
      }
    }

    Input input = gc.getInput();

    hoveredPart = null;

    for (int i = 0; i < inventoryBoxes.size(); i++) {
      if (inventoryBoxes.get(i).getRectangle().contains(input.getMouseX(), input.getMouseY())) {
        if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
          if (inventoryBoxes.get(i).getPart().equals(selectedPart)) {
            // Deselects if already selected
            selectedPart = null;
          } else {
            // Selects if not already selected
            selectedPart = inventoryBoxes.get(i).getPart();
          }
        } else {
          hoveredPart = inventoryBoxes.get(i).getPart();
        }
        break;
      }
    }
  }
Example #23
0
  @Override
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    // TODO Auto-generated method stub
    Input input = container.getInput();
    int mouseX = input.getMouseX();
    int mouseY = input.getMouseY();
    boolean inMenu = false;

    if (mouseX > 400 && mouseX < 626 && mouseY > 200 && mouseY < 276) inMenu = true;
    if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) && inMenu) {
      Constant.LEVEL = 0;
      game.enterState(3);
    }
  }
  public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i)
      throws SlickException {

    Input input = gameContainer.getInput();

    calendar.tick();
    if (counter == 3) {
      gamePanel.update(
          input,
          input.getMouseX(),
          input.getMouseY(),
          input.isMousePressed(Input.MOUSE_LEFT_BUTTON));
      counter = 0;
    }
    counter++;
  }
Example #25
0
  /**
   * Create a new mouse over area
   *
   * @param container The container displaying the mouse over area
   * @param image The normalImage to display
   * @param shape The shape defining the area of the mouse sensitive zone
   */
  public MouseOverArea(GUIContext container, Image image, Shape shape) {
    super(container);

    area = shape;
    normalImage = image;
    currentImage = image;
    mouseOverImage = image;
    mouseDownImage = image;

    currentColor = normalColor;

    state = NORMAL;
    Input input = container.getInput();
    over = area.contains(input.getMouseX(), input.getMouseY());
    mouseDown = input.isMouseButtonDown(0);
    updateImage();
  }
Example #26
0
 @Override
 public void poll(Input input, float secounds) {
   if (selected == this || selected == null) {
     Vector mousePos = this.getEditor().translateMousePos(input.getMouseX(), input.getMouseY());
     if (this.wasInCircle) {
       this.changePosition(mousePos);
     }
     if ((this.shape.isPointIn(mousePos) || this.wasInCircle)
         && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
       this.wasInCircle = true;
       selected = this;
     } else {
       this.wasInCircle = false;
       selected = null;
     }
   }
 }
  private void handleKeyboardInput(Input i, int delta) {
    // we can both use the WASD or arrow keys to move around, obviously we can't move both left and
    // right simultaneously
    if (i.isKeyDown(Input.KEY_A) || i.isKeyDown(Input.KEY_LEFT)) {
      player.moveLeft(delta);
    } else if (i.isKeyDown(Input.KEY_D) || i.isKeyDown(Input.KEY_RIGHT)) {
      player.moveRight(delta);
    } else {
      // we dont move if we don't press left or right, this will have the effect that our player
      // decelerates
      player.setMoving(false);
    }

    if (i.isKeyDown(Input.KEY_SPACE)) {
      player.jump();
    }
  }
Example #28
0
  @Override
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    final int X_DECCEL = 2;
    final int Y_ACCEL = 3;

    // Player movement
    Player p = getPlayer();
    if (!p.isAlive()) {
      Sound fx = null;
      if (playDeathSound) {
        fx = new Sound("res/audio/sounds/FallAndSplat.wav");
        fx.play();
        playDeathSound = false;
      }
      while (!fx.playing()) {
        container.exit();
      }
    }
    // Account for input
    Input i = container.getInput();
    if (i.isKeyDown(Input.KEY_D)) {
      p.accelerate(new Vector2f(4, 0));
    }
    if (i.isKeyDown(Input.KEY_A)) {
      p.accelerate(new Vector2f(-4, 0));
    }
    if (i.isKeyPressed(Input.KEY_W)) {
      p.jump();
    }

    Vector2f playerVect = p.getAccelerationVector();
    // Deccelerate X
    if (playerVect.x < 4 && playerVect.x > -4) {
      p.accelerate(new Vector2f(-1 * playerVect.x, 0));
    } else if (playerVect.x >= 4) {
      p.accelerate(new Vector2f(-1 * X_DECCEL, 0));
    } else {
      p.accelerate(new Vector2f(X_DECCEL, 0));
    }

    // Accellerate Y
    p.accelerate(new Vector2f(0, Y_ACCEL));
    p.move();
    this.manageCollision(true, true, true);
  }
Example #29
0
  public void update(GameContainer container, StateBasedGame game, int delta)
      throws SlickException {
    Input input = container.getInput();

    for (int i = 0; i < allMapTab.length; i++) {
      levelB[i].update(container);
    }
    for (int i = 0; i < allMapTab.length; i++) {
      if (levelB[i].isClicked() && (i + 1) <= Fenetre.profilActif.getNiveaux_debloque()) {
        Fenetre.profilActif.setCurrent_Level(i + 1);
        Fenetre.profilActif.setLevel(Fenetre.profilActif.getCurrent_Level());
        game.enterState(PlayLevel.ID);
      }
    }
    if (input.isKeyPressed(Keyboard.KEY_ESCAPE)) {
      game.enterState(MenuGame.ID);
    }
  }
Example #30
0
  public PathBuildingFollower(final Path path, int nodeRadius, GameContainer container) {
    super(path, nodeRadius);
    path.addNode(new Vector2f(container.getWidth() / 2, container.getHeight() / 2));
    Input input = container.getInput();
    input.addMouseListener(
        new InputAdapter() {
          @Override
          public void mousePressed(int button, int x, int y) {
            if (button == 0) path.addNode(new Vector2f(x, y));
            else if (button == 1) path.removeLastNodes();
          }

          @Override
          public void mouseDragged(int oldx, int oldy, int newx, int newy) {
            path.addNode(new Vector2f(newx, newy));
          }
        });
  }