Beispiel #1
0
  @Override
  public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int delta)
      throws SlickException {
    super.update(gameContainer, stateBasedGame, delta);
    rotation += (targetrotation - rotation) / rotationEase;
    tandwiel1.setRotation(rotation);
    tandwiel2.setRotation((float) ((float) -(rotation * 1.818181818181818) + 16.36363636363636));
    spinner.setRotation(rotation);

    if (frameGrabber != null && updateCamera) {
      updateCamera = false;
      buffer = frameGrabber.grabFrame();
      awtFrame = new BufferToImage((VideoFormat) buffer.getFormat()).createImage(buffer);
      BufferedImage bufferedImage =
          new BufferedImage(
              awtFrame.getWidth(null), awtFrame.getHeight(null), BufferedImage.TYPE_INT_RGB);
      bufferedImage.createGraphics().drawImage(awtFrame, 0, 0, this);
      baseImage = bufferedImage;
      try {
        texture = BufferedImageUtil.getTexture("", baseImage);
        webcamFeed.setTexture(texture);
      } catch (IOException e) {
        logger.error(e);
      }
    }
    calculatePulse();
  }
Beispiel #2
0
 public void render(GameContainer container, Graphics g) throws SlickException {
   if (isFlippedHorizontally) {
     currentImage = imageLeft;
     spinAngularVelocity = -15;
   } else {
     currentImage = imageRight;
     spinAngularVelocity = 15;
   }
   spinAngle += spinAngularVelocity;
   currentImage.setRotation(spinAngle);
   currentImage.draw(xCoord, yCoord);
   // g.draw(getHitbox());
 }
Beispiel #3
0
 /**
  * constructor that creates a new projectile at a specified value
  *
  * @param startX - starting x value
  * @param startY - starting y value
  * @param dir - direction the projectile is moving in
  * @throws SlickException - exception that specifies the issue is related to slick2d game library
  */
 public Projectile(double startX, double startY, String dir) throws SlickException {
   image = new Image("res/arrow.png");
   myX = startX;
   myY = startY;
   origX = startX;
   origY = startY;
   direction = dir;
   switch (direction) {
     case "right":
       image.setRotation(45);
       break;
     case "left":
       image.setRotation(-135);
       break;
     case "up":
       image.setRotation(-45);
       break;
     case "down":
       image.setRotation(135);
       break;
   }
 }
Beispiel #4
0
 @Override
 public void sprint(Graphics g, float fsX, float fsY) throws SlickException {
   kunai.setAlpha(1);
   if (this.getAnim() == this.getWalkingDown()) {
     kunai.setCenterOfRotation(0, 0);
     kunai.setRotation(94 - (System.currentTimeMillis() % 8));
     g.drawImage(kunai, fsX + 12, fsY + 24);
   }
   if (this.getAnim() == this.getWalkingUp()) {
     kunai.setCenterOfRotation(0, 0);
     kunai.setRotation(-(94 - (System.currentTimeMillis() % 8)));
     g.drawImage(kunai, fsX + 20, fsY + 24);
   }
   if (this.getAnim() == this.getWalkingLeft()) {
     kunai.setCenterOfRotation(0, 0);
     kunai.setRotation(184 - (System.currentTimeMillis() % 8));
     g.drawImage(kunai, fsX + 12, fsY + 32);
   }
   if (this.getAnim() == this.getWalkingRight()) {
     kunai.setCenterOfRotation(0, 0);
     kunai.setRotation(4 - (System.currentTimeMillis() % 8));
     g.drawImage(kunai, fsX + 16, fsY + 18);
   }
 }
  public void fly() {
    if (!isFlying()) {
      return;
    }

    setRotation(getRotation() % 360);
    if (remainingFuel <= 0) {
      setFlying(false);
      return;
    }
    remainingFuel -= fuelConsumptionRate;
    remainingFuel = (remainingFuel < 0) ? 0 : remainingFuel;

    float theRot = (float) Math.toRadians(getRotation());
    float xVec, yVec;
    xVec = (float) Math.sin(theRot) * 10000;
    yVec = (float) Math.cos(theRot) * (-800);

    if (getRotation() <= 180 || getRotation() >= 270) {
      yVec = (yVec > -600) ? -600 : yVec;
    } else {
      yVec -= 200;
    }
    this.applyForce(xVec, yVec - 200);

    sprayImage = sprayImage.getFlippedCopy(true, false);
    theRot = (float) Math.toRadians(getRotation());
    sprayImage.setRotation(theRot);
    float oldX = getVisualX();
    float oldY = getVisualY();
    float newX;
    float newY;

    try {
      AffineTransform transformer = AffineTransform.getRotateInstance(theRot, oldX, oldY);
      Point2D before = new Point2D.Double(oldX, oldY + 60);
      Point2D after = new Point2D.Double();
      after = transformer.transform(before, after);

      newX = (float) after.getX();
      newY = (float) after.getY();
      sprayX = newX;
      sprayY = newY;
    } catch (Exception e) {
      System.out.println(e);
    }
  }
Beispiel #6
0
  @Override
  public void attack(Graphics g, float fsX, float fsY) throws SlickException {
    // g.drawOval(fsX-32, fsY-32, 64+32, 64+32);

    // Image kunai = new Image("res/ninja/kunai.png");

    long time2 = 8 + (System.currentTimeMillis() / 15) % (32 - 8);
    for (int i = 360; i > 0; i -= 45) {
      kunai.setCenterOfRotation(0, 0);
      kunai.setRotation(i);
      float alp = (32 - (time2));
      kunai.setAlpha((float) Math.pow((alp) / 32, 0.1));
      g.drawImage(
          kunai,
          (float) ((fsX + 16) + (1 * time2 * Math.cos(i * 0.0174532925))),
          (float) ((fsY + 16) + (1 * time2 * Math.sin(i * 0.0174532925))));
    }

    // g.drawImage(kunai, fsX-time2, fsY+8);
    // this.setAnim(Ninja.getAttack());
  }
Beispiel #7
0
    public void render(Graphics g) {
      // g.drawOval(x, y, 30, 30);
      life--;

      angle += (rotation + 360) % 360;
      x += dX;
      y += dY;

      // set alpha
      if (life < 20) {
        alpha -= 0.05f;
      } else if (alpha < 1) {
        alpha += 0.05f;
      }

      Image snow = ERM.getImage("menu_snow");
      Image temp = snow.getScaledCopy(scale);
      temp.setRotation(angle);
      temp.setAlpha(alpha);
      g.drawImage(temp, x, y - snowLife * 2);
    }
  @Override
  public void render(GameContainer gc, Graphics g) throws SlickException {

    if (!isMoving()) {
      setImage(sheet.getSprite("little_robot_00.png"));
      initialImage = getImage();
    }

    if (isJumping()) {
      currentState = "Jumping";
    } else if (isFalling()) {
      currentState = "Falling";
    } else if (isOnGround()) {
      if (isMoving()) currentState = "isMoving";
      else {
        currentState = "OnGround";
      }
    }

    setImage(initialImage);

    if (!isFacingRight()) {
      setImage(initialImage.getFlippedCopy(true, false));
    }

    if (isMoving() && isOnGround()) {
      currentState = "rotating -> " + getRotation();
    }
    getImage().setRotation(getRotation());
    getImage().drawCentered(getVisualX(), getVisualY());

    if (isFlying()) {
      sprayImage.setRotation(getRotation());
      sprayImage.drawCentered(sprayX, sprayY);
    }
  }
Beispiel #9
0
  @Override
  public void draw(Graphics g, int trackPosition) {
    int timeDiff = hitObject.getTime() - trackPosition;
    float scale = timeDiff / (float) game.getApproachTime();
    float fadeinScale = (timeDiff - game.getApproachTime() + FADE_IN_TIME) / (float) FADE_IN_TIME;
    float approachScale = 1 + scale * 3;
    float alpha = Utils.clamp(1 - fadeinScale, 0, 1);
    boolean overlayAboveNumber = Options.getSkin().isHitCircleOverlayAboveNumber();

    float oldAlpha = Utils.COLOR_WHITE_FADE.a;
    Utils.COLOR_WHITE_FADE.a = color.a = alpha;
    Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
    Image hitCircle = GameImage.HITCIRCLE.getImage();
    float[] endPos = curve.pointAt(1);

    curve.draw(color);
    color.a = alpha;

    // end circle
    hitCircle.drawCentered(endPos[0], endPos[1], color);
    hitCircleOverlay.drawCentered(endPos[0], endPos[1], Utils.COLOR_WHITE_FADE);

    // start circle
    hitCircle.drawCentered(x, y, color);
    if (!overlayAboveNumber) hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE);

    // ticks
    if (ticksT != null) {
      Image tick = GameImage.SLIDER_TICK.getImage();
      for (int i = 0; i < ticksT.length; i++) {
        float[] c = curve.pointAt(ticksT[i]);
        tick.drawCentered(c[0], c[1], Utils.COLOR_WHITE_FADE);
      }
    }
    if (sliderClickedInitial) ; // don't draw current combo number if already clicked
    else
      data.drawSymbolNumber(
          hitObject.getComboNumber(),
          x,
          y,
          hitCircle.getWidth() * 0.40f / data.getDefaultSymbolImage(0).getHeight(),
          alpha);
    if (overlayAboveNumber) hitCircleOverlay.drawCentered(x, y, Utils.COLOR_WHITE_FADE);

    // repeats
    for (int tcurRepeat = currentRepeats; tcurRepeat <= currentRepeats + 1; tcurRepeat++) {
      if (hitObject.getRepeatCount() - 1 > tcurRepeat) {
        Image arrow = GameImage.REVERSEARROW.getImage();
        if (tcurRepeat != currentRepeats) {
          if (sliderTime == 0) continue;
          float t = Math.max(getT(trackPosition, true), 0);
          arrow.setAlpha((float) (t - Math.floor(t)));
        } else arrow.setAlpha(1f);
        if (tcurRepeat % 2 == 0) {
          // last circle
          arrow.setRotation(curve.getEndAngle());
          arrow.drawCentered(endPos[0], endPos[1]);
        } else {
          // first circle
          arrow.setRotation(curve.getStartAngle());
          arrow.drawCentered(x, y);
        }
      }
    }

    if (timeDiff >= 0) {
      // approach circle
      GameImage.APPROACHCIRCLE.getImage().getScaledCopy(approachScale).drawCentered(x, y, color);
    } else {
      // Since update() might not have run before drawing during a replay, the
      // slider time may not have been calculated, which causes NAN numbers and flicker.
      if (sliderTime == 0) return;

      float[] c = curve.pointAt(getT(trackPosition, false));
      float[] c2 = curve.pointAt(getT(trackPosition, false) + 0.01f);

      float t = getT(trackPosition, false);
      //			float dis = hitObject.getPixelLength() * HitObject.getXMultiplier() * (t - (int) t);
      //			Image sliderBallFrame = sliderBallImages[(int) (dis / (diameter * Math.PI) * 30) %
      // sliderBallImages.length];
      Image sliderBallFrame =
          sliderBallImages[(int) (t * sliderTime * 60 / 1000) % sliderBallImages.length];
      float angle = (float) (Math.atan2(c2[1] - c[1], c2[0] - c[0]) * 180 / Math.PI);
      sliderBallFrame.setRotation(angle);
      sliderBallFrame.drawCentered(c[0], c[1]);

      // follow circle
      if (followCircleActive) {
        GameImage.SLIDER_FOLLOWCIRCLE.getImage().drawCentered(c[0], c[1]);

        // "flashlight" mod: dim the screen
        if (GameMod.FLASHLIGHT.isActive()) {
          float oldAlphaBlack = Utils.COLOR_BLACK_ALPHA.a;
          Utils.COLOR_BLACK_ALPHA.a = 0.75f;
          g.setColor(Utils.COLOR_BLACK_ALPHA);
          g.fillRect(0, 0, containerWidth, containerHeight);
          Utils.COLOR_BLACK_ALPHA.a = oldAlphaBlack;
        }
      }
    }

    Utils.COLOR_WHITE_FADE.a = oldAlpha;
  }
Beispiel #10
0
 public void draw() {
   Image rotated = image.copy();
   if (moving) rotated.setRotation((float) Math.toDegrees(angle));
   rotated.draw(x, y);
 }
Beispiel #11
0
 public void draw(float xCoordinate, float yCoordinate, float rotation, float scale) {
   super.setRotation(rotation);
   super.draw(xCoordinate + xOffset, yCoordinate + yOffset, scale);
 }