예제 #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
파일: Filters.java 프로젝트: Vortif/ps
 private static void setRGBMatrix() {
   int height = (int) image.getHeight();
   int width = (int) image.getWidth();
   imgR = new double[width][height];
   imgG = new double[width][height];
   imgB = new double[width][height];
   PixelReader reader = image.getPixelReader();
   for (int readY = 0; readY < height; readY++) {
     for (int readX = 0; readX < width; readX++) {
       Color color = reader.getColor(readX, readY);
       imgG[readX][readY] = color.getGreen();
       imgB[readX][readY] = color.getBlue();
       imgR[readX][readY] = color.getRed();
     }
   }
 }