Package gameobjects

Class RectObject


public class RectObject extends GameObject
A rectangle object.
If generateColliders() is called, it generates a RectCollider with id-prefix "shotcollider_" and registers it for this RectObject.
  • Constructor Details

    • RectObject

      public RectObject(String id, Playground pg, double x, double y, double vx, double vy, double width, double height, Color color)
      Initializes the RectObject with a suitable RectArtist for drawing the RectObject.
      Parameters:
      id - String unique name to be used.
      pg - Playground instance this RectObject belongs to (the level it belongs to).
      x - position in horizontal direction in pixels (zero or positive number).
      y - position in vertical direction in pixels (zero or positive number).
      vx - speed/velocity in horizontal direction in pixels (negative, zero or positive number).
      vy - speed/velocity in vertical direction in pixels (negative, zero or positive number).
      width - in pixels
      height - in pixels
      color - solid color for the whole object, used to initialize an instance of RectArtist used for this RectObject.
  • Method Details

    • generateColliders

      public RectObject generateColliders()
      generates a new RectCollider with id-prefix "shotcollider_" and registers it for 'this' [@link RectObject}. The RectCollider uses the same dimensions (width and height) as this RectObject.
      Overrides:
      generateColliders in class GameObject
      Returns:
      this RectObject itself
    • getWidth

      public double getWidth()
      Getter for the width
      Returns:
      double width value as set by constructor
    • getHeight

      public double getHeight()
      Getter for the height
      Returns:
      double height value as set by constructor