예제 #1
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);
  }
예제 #2
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();
    }
  }