Beispiel #1
0
  public MoveSubprogram(GameObject obj, float len) {
    super(String.format("MoveSubprogram_%s", obj.getName()));

    movedObject = obj;
    length = len;
    checkLength = len > 0;
  }
Beispiel #2
0
  @Override
  public void onUpdate() {
    IWorld world = GameContext.content.getWorld();
    GameDescription description = movedObject.getDescription();

    float stepLength = description.getSpeed() * GameContext.getDelta();
    GameContext.collisions.move(movedObject, stepLength);

    if (checkLength) {
      length -= stepLength;
      if (length < 0) world.remove(movedObject);
    }
  }