java.lang.Object
org.openpatch.scratch.extensions.hitbox.Hitbox

public class Hitbox extends Object
Represents a hitbox with a shape that can be transformed by scaling, translating, and rotating it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Hitbox(int[] xPoints, int[] yPoints)
    Constructs a hitbox with the specified x and y points.
    Hitbox(Shape shape)
    Constructs a hitbox with the specified shape.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Checks if the hitbox contains a point.
    void
    drawDebug(processing.core.PGraphics buffer)
    Draws the hitbox with a debug color.
    void
    drawShape(processing.core.PGraphics buffer)
    Draws the shape.
    Returns the shape of the hitbox.
    boolean
    Checks if the hitbox intersects with another hitbox.
    void
    translateAndRotateAndResize(double degrees, double originX, double originY, double translateX, double translateY, double size)
    Transforms the shape by scaling, translating, and rotating it.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Hitbox

      public Hitbox(Shape shape)
      Constructs a hitbox with the specified shape.
      Parameters:
      shape - The shape of the hitbox.
    • Hitbox

      public Hitbox(int[] xPoints, int[] yPoints)
      Constructs a hitbox with the specified x and y points.
      Parameters:
      xPoints - The x-coordinates of the points.
      yPoints - The y-coordinates of the points.
  • Method Details

    • getShape

      public Shape getShape()
      Returns the shape of the hitbox.
      Returns:
      The shape of the hitbox.
    • translateAndRotateAndResize

      public void translateAndRotateAndResize(double degrees, double originX, double originY, double translateX, double translateY, double size)
      Transforms the shape by scaling, translating, and rotating it.
      Parameters:
      degrees - The angle in degrees to rotate the shape.
      originX - The x-coordinate of the rotation origin.
      originY - The y-coordinate of the rotation origin.
      translateX - The x-coordinate to translate the shape.
      translateY - The y-coordinate to translate the shape.
      size - The size to scale the shape, where 100.0 represents the original size.
    • drawDebug

      public void drawDebug(processing.core.PGraphics buffer)
      Draws the hitbox with a debug color.
      Parameters:
      buffer - The buffer to draw the hitbox on.
    • contains

      public boolean contains(double x, double y)
      Checks if the hitbox contains a point.
      Parameters:
      x - The x-coordinate of the point.
      y - The y-coordinate of the point.
      Returns:
      true if the hitbox contains the point, false otherwise.
    • intersects

      public boolean intersects(Hitbox hitbox)
      Checks if the hitbox intersects with another hitbox.
      Parameters:
      hitbox - The hitbox to check for intersection.
      Returns:
      true if the hitboxes intersect, false otherwise.
    • drawShape

      public void drawShape(processing.core.PGraphics buffer)
      Draws the shape.
      Parameters:
      buffer - The buffer to draw the shape on.