예제 #1
0
  /**
   * Do a low level pixel perfect hit test.
   *
   * @param x The x coordinate to test, relative to the origin of this animation's tile
   * @param y The y coordinate to test, relative to the origin of this animation's tile
   * @param frame The frame to hit test on
   * @param angle The angle of the camera
   * @param direction The direction the sprite is facing
   * @return true if the hit test passes.
   */
  public boolean hitTest(int x, int y0, int frame, CameraAngle angle, FacingDirection direction) {
    int y = y0 + h - ((int) GlobalConstants.TILEH);
    if (x < 0 || x >= w || y < 0 || y >= h) return false;

    int rotation = direction.transform(angle);
    int xt = (int) ((double) (x + (frame * GlobalConstants.TILEW)) / sf);
    int yt = (int) ((double) (y + (rotation * h)) / sf);

    return hitTester.getColor(xt, yt).isOpaque();
  }
예제 #2
0
 public void renderFrame(
     GraphicsContext cx,
     int xoff,
     int w1,
     int frame,
     CameraAngle angle,
     FacingDirection direction) {
   frame = frame % frames;
   int rotation = direction.transform(angle);
   cx.setFill(frameTextures[(frame * 4) + rotation]);
   cx.fillRect(xoff, 0, w1, h);
 }