@Override
  protected void stopAction() {
    Vector2f pos = getLevelBowPosition();
    Vector2f speed = controllerUtils.getCurrentDirection(SPEED, getScreenBowPosition());

    projectileController.add(
        new Arrow(
            pos.getX(), pos.getY(), playerController.getPlayer(), speed.getX(), speed.getY()));
    soundController.play(bowSound, 0.7f);
  }
 public void spawnBirds() {
   for (Vector2f coordinate :
       birdformations.getRandomBirdFormation(
           (random.nextFloat() * 1300) + 0, (random.nextFloat() * 420) + 0)) {
     sceneHandler.spawn(coordinate.getX(), coordinate.getY(), PBird.class);
   }
 }
    /**
     * Get the value to use at a given time value
     *
     * @param t The time value (expecting t in [0,1])
     * @return The value to use at the specified time
     */
    @Override
    public float getValue(float t) {
      // first: determine the segment we are in
      Vector2f p0 = curve.get(0);
      for (int i = 1; i < curve.size(); i++) {
        Vector2f p1 = curve.get(i);

        if (t >= p0.getX() && t <= p1.getX()) {
          // found the segment
          float st = (t - p0.getX()) / (p1.getX() - p0.getX());
          float r = p0.getY() + st * (p1.getY() - p0.getY());
          // System.out.println( "t: " + t + ", " + p0.x + ", " + p0.y + " : " + p1.x + ", " + p1.y
          // + " => " + r );

          return r;
        }

        p0 = p1;
      }
      return 0;
    }
Beispiel #4
0
 void update(Timer timer) {
   if (pathing) {
     distance = position.distance(target);
     float x = (target.getX() - position.getX());
     float y = (target.getY() - position.getY());
     float vx = speed * slf * (x / distance);
     float vy = speed * slf * (y / distance);
     velocity.set(vx, vy);
     scaledVelocity.set(vx * scale, vy * scale);
     if ((timer.getTick() % (timer.getTimerSetting().getSpeed() * 0.05f)) == 0) {
       Vector2f v = velocity.scale(0.05f);
       // Vector2f sv = velocity.scale(0.05f);
       if (distance < 1f) {
         position.set(target);
         setPosition(position.getX(), position.getY());
       } else {
         position.set(position.getX() + (v.getX() * scale), position.getY() + (v.getY() * scale));
         setPosition(position.getX(), position.getY());
       }
     }
   }
 }
 protected void translate(Vector2f difference) {
   this.position =
       new Point(
           this.position.getX() + difference.getX(), this.position.getY() + difference.getY());
 }