Ejemplo n.º 1
0
  // propagate logic
  public void moveBullet(float ms) {
    // the bigger amount of pixels to move.
    float steps =
        (Math.abs(xVel * ms) > Math.abs(yVel * ms)) ? Math.abs(xVel * ms) : Math.abs(yVel * ms);

    steps += 1;

    float deltaX = (xVel * ms) / steps;
    float deltaY = (yVel * ms) / steps;

    for (int i = 0; i != (int) (steps + 1); i++) {
      shape.setX(shape.getX() + deltaX);
      shape.setY(shape.getY() + deltaY);

      for (SPlayer p : SState.players) {

        if (p != null) {
          if (p.intersects(shape)) {
            p.hurt(damage);
            live = false;
            return;
          }
        }
      }

      if (SState.map.checkCollide(getShape())) {
        live = false;
        return;
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * Set the x coordinate of this area
  *
  * @param x The new x coordinate of this area
  */
 public void setX(float x) {
   area.setX(x);
 }
Ejemplo n.º 3
0
 /**
  * Moves the component.
  *
  * @param x X coordinate
  * @param y Y coordinate
  */
 public void setLocation(float x, float y) {
   if (area != null) {
     area.setX(x);
     area.setY(y);
   }
 }