@Override
  public void update(GameContainer gc, StateBasedGame sb, int delta) throws SlickException {
    background.rotate(0.05F * delta);
    Input input = gc.getInput();

    if (input.isKeyPressed(Input.KEY_ESCAPE)) sb.enterState(0);
    if (input.isKeyPressed(Input.KEY_DOWN)) {
      // Wenn ausgewählter Index + 1 kleiner als die Items auf der Seite sind, erhöre den Index
      if (currentIndex + 1 < itemsOnSide) currentIndex++;
    }
    if (input.isKeyPressed(Input.KEY_UP)) {
      // gleiches wie oben, nur andersrum
      if (currentIndex != 0) currentIndex--;
    }
    if (input.isKeyPressed(Input.KEY_RIGHT)) {
      // Seite wechseln
      if (side + 1 < sideCount) {
        currentIndex = 0;
        side++;
        start = side * 10 + 1;
        end = start + 9;
      }
    }
    if (input.isKeyPressed(Input.KEY_LEFT)) {
      // Seite wechseln
      if (side - 1 >= 0) {
        currentIndex = 0;
        side--;
        start = side * 10 + 1;
        end = start + 9;
      }
    }
    count = 0;

    // Anpassung des Selection-Rectangles
    // Muss immer auf die Breite/Position des jeweiligen MenuItems angepasst werden
    for (MenuItem item : levelNames) {
      if (count == currentIndex + start) {
        selection.setLocation(item.getPos().x - 5, item.getPos().y - 5);
      }
      count++;
    }
    count = 0;
    for (MenuItem item : times) {
      if (count == currentIndex + start) {
        selection.setWidth(
            item.getPos().x + uniNormal.getWidth(item.getName()) - selection.getX() + 5);
      }
      count++;
    }
  }
  @Override
  public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
    // Images
    backgroundImage = Global.setImage("papyrus_page.png");
    backgroundImage.rotate(90);
    mapImage = Global.setImage("scroll_background_page_horizontal.png");
    mapLvlDefaultImage = Global.setImage("bloque_niveau.png");
    mapLvlUnlockedImage = Global.setImage("debut_niveau.png");
    mapLvlUnlockedFinishedImage = Global.setImage("fin_niveau.png");
    mapLvlFinishedImage = Global.setImage("fin_niveau.png");

    // Labels
    newGameImage = Global.setImage("main_menu_nouvelle_partie.png");
    newGameImage =
        newGameImage.getScaledCopy(
            (int) (newGameImage.getWidth() * SCALE_DOWN_W), newGameImage.getHeight());

    loadGameImage = Global.setImage("main_menu_charger_partie.png");
    loadGameImage =
        loadGameImage.getScaledCopy(
            (int) (loadGameImage.getWidth() * SCALE_DOWN_W), loadGameImage.getHeight());

    if (optionsActivated) {
      optionsImage = Global.setImage("main_menu_options.png");
      optionsImage =
          optionsImage.getScaledCopy(
              (int) (optionsImage.getWidth() * SCALE_DOWN_W), optionsImage.getHeight());
    }

    titleImage = Global.setImage("main_menu_title.png");
    titleImage =
        titleImage.getScaledCopy(
            (int) (titleImage.getWidth() * SCALE_DOWN_W * 1.5), titleImage.getHeight());

    display = new Display(gc);
    Image labelImage = Global.setImage(Global.BUTTON_STANDARD_IMAGE);
    Image playerImage = labelImage.getScaledCopy(150, 25);
    mapErrorLabel = new Label(playerImage, "");
    mapErrorLabel.setForeground(Color.red);
    mapErrorLabel.setBounds(800 - ERROR_X - ERROR_W, ERROR_Y, ERROR_W, ERROR_H);
    mapErrorLabel.pack();
    this.display.add(mapErrorLabel);
    mapErrorLabel.setImage(null);
  }
Esempio n. 3
0
  /**
   * Renders the player to the screen
   *
   * @param x the x position to render the player to
   * @param y the y position to render the player to
   * @param g the graphics context
   * @param viewerRole the role of the one viewing this player
   */
  public void draw(float x, float y, Graphics g, Role viewerRole) {

    if (Role.isRestriced(viewerRole) && "Fuzzi_Traitor.png".equals(texture)) {
      image = RessourceManager.loadImage("Fuzzi_Innocent.png");
    } else image = RessourceManager.loadImage(texture);

    image.rotate(lookAngle - image.getRotation() + 90);
    image.draw(x, y);

    if (this.getInventory()[this.getCurrentWeapon()] != null)
      this.getInventory()[this.getCurrentWeapon()].draw(x, y);

    g.setColor(Color.black);
    g.drawRect(x, y - 12, 32, 8);
    g.setColor(Color.red);
    g.fillRect(x + 1, y - 11, lifepoints * 0.31f, 7);

    Vector2f v = new Vector2f(x + 16, y + 16);
    Vector2f v1 = new Vector2f(getLookAngle()).scale(130f);
    Vector2f v2 = v.copy().add(v1);

    g.drawLine(v.x, v.y, v2.x, v2.y);
  }
Esempio n. 4
0
  @Override
  public void update(GameContainer container, int delta) throws SlickException {
    // throw new UnsupportedOperationException("Not supported yet.");
    Input input = container.getInput();

    // rotate quad
    double x1 = jugador1.getPosicion().getX();
    double y1 = jugador1.getPosicion().getY();

    if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) {
      plane1.rotate(-0.2f * delta);
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
      plane1.rotate(0.2f * delta);
    }

    if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
      float hip = 0.4f * delta;
      float rotation = plane1.getRotation();
      x1 -= hip * Math.sin(Math.toRadians(rotation));
      y1 += hip * Math.cos(Math.toRadians(rotation));
    }
    if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
      float hip = 0.4f * delta;
      float rotation = plane1.getRotation();
      x1 += hip * Math.sin(Math.toRadians(rotation));
      y1 -= hip * Math.cos(Math.toRadians(rotation));
    }

    // keep quad on the screen
    if (x1 < 10) {
      x1 = 10;
    }
    if (x1 > 790) {
      x1 = 790;
    }
    if (y1 < 10) {
      y1 = 10;
    }
    if (y1 > 590) {
      y1 = 590;
    }

    Vector posicion = jugador1.getPosicion();
    posicion.setX(x1);
    posicion.setY(y1);
    jugador1.setPosicion(posicion);

    // jugador 2
    if (Keyboard.isKeyDown(Keyboard.KEY_W)) lastSteering = 1;
    if (Keyboard.isKeyDown(Keyboard.KEY_A)) lastSteering = 2;
    if (Keyboard.isKeyDown(Keyboard.KEY_F)) lastSteering = 3;
    if (Keyboard.isKeyDown(Keyboard.KEY_S)) lastSteering = 4;
    /*
    switch(lastSteering) {
        case 1: jugador2.update(steeringW.getSteering(), delta);
            break;
        case 2: jugador2.update(steeringA.getSteering(), delta);
            break;
        case 3: jugador2.update(steeringF.getSteering(), delta);
            break;
        case 4: jugador2.update(steeringS.getSteering(), delta);
            break;
        default:
    }*/

    // plane2.rotate((float) jugador2.getOrientacion());

    if (input.isKeyPressed(Input.KEY_F1)) {
      Image target = new Image(container.getWidth(), container.getHeight());
      container.getGraphics().copyArea(target, 0, 0);
      ImageOut.write(target.getFlippedCopy(false, true), "screenshot.png", false);
      target.destroy();
    }
  }
Esempio n. 5
0
 public void rotate(float rotation, Image ship) {
   ship.rotate(rotation);
 }