Class GameObject

java.lang.Object
de.tum.cit.fop.maze.objects.GameObject
Direct Known Subclasses:
Collectable, Dawn, Enemy, Exit, Player, Trap

public abstract class GameObject extends Object
Base class for all game objects with position, movement, and animation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.badlogic.gdx.math.Rectangle
     
    protected AnimationType
     
    protected Drawable
     
    com.badlogic.gdx.math.Vector2
     
    protected com.badlogic.gdx.math.Vector2
     
    float
     
    protected float
     
    protected com.badlogic.gdx.math.Vector2
     
    protected com.badlogic.gdx.graphics.g2d.TextureRegion
     
    com.badlogic.gdx.math.Vector2
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    GameObject(float x, float y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
     
    GameObject(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 velocity, float speed, com.badlogic.gdx.math.Vector2 sizes, com.badlogic.gdx.math.Vector2 spriteSizes, AnimationType initialAnimationType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    animate(com.badlogic.gdx.graphics.g2d.Batch batch)
    Renders the object using its drawable or texture.
    void
    Changes the current animation.
    static Boolean
    entitiesOverlap(GameObject gameObject1, GameObject gameObject2)
    Checks if two game objects overlap.
    com.badlogic.gdx.math.Rectangle
    Gets the object's collision bounds.
    Gets the drawable component.
    com.badlogic.gdx.math.Vector2
    Gets the object's hitbox size.
    float
    Gets the object's current speed including modifiers.
    com.badlogic.gdx.math.Vector2
    Gets the object's velocity vector.
    void
    increaseSpeed(float extraSpeed)
    Increases the object's speed by a value.
    void
    move(float deltaTime)
    Moves the object by its velocity over time.
    void
    multiplySpeed(float multiplier)
    Multiplies the speed multiplier.
    com.badlogic.gdx.math.Vector2
    nextPosition(float deltaTime)
    Calculates next position based on current velocity.
    void
    setAnimationTime(float time)
    Sets the animation time for the drawable.
    void
    updateAnimation(float delta)
    Updates animation state and bounds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • position

      public com.badlogic.gdx.math.Vector2 position
    • velocity

      public com.badlogic.gdx.math.Vector2 velocity
    • speed

      public float speed
    • texture

      protected com.badlogic.gdx.graphics.g2d.TextureRegion texture
    • speedMultiplier

      protected float speedMultiplier
    • sizes

      protected com.badlogic.gdx.math.Vector2 sizes
    • spriteSizes

      protected com.badlogic.gdx.math.Vector2 spriteSizes
    • drawable

      protected Drawable drawable
    • bounds

      protected com.badlogic.gdx.math.Rectangle bounds
    • currentAnimationType

      protected AnimationType currentAnimationType
  • Constructor Details

    • GameObject

      public GameObject(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.math.Vector2 velocity, float speed, com.badlogic.gdx.math.Vector2 sizes, com.badlogic.gdx.math.Vector2 spriteSizes, AnimationType initialAnimationType)
    • GameObject

      public GameObject(float x, float y, com.badlogic.gdx.graphics.g2d.TextureRegion texture)
  • Method Details

    • entitiesOverlap

      public static Boolean entitiesOverlap(GameObject gameObject1, GameObject gameObject2)
      Checks if two game objects overlap.
      Parameters:
      gameObject1 - First object
      gameObject2 - Second object
      Returns:
      True if objects overlap
    • getSize

      public com.badlogic.gdx.math.Vector2 getSize()
      Gets the object's hitbox size.
      Returns:
      Size vector
    • getSpeed

      public float getSpeed()
      Gets the object's current speed including modifiers.
      Returns:
      Effective speed value
    • getBounds

      public com.badlogic.gdx.math.Rectangle getBounds()
      Gets the object's collision bounds.
      Returns:
      Updated bounds rectangle
    • setAnimationTime

      public void setAnimationTime(float time)
      Sets the animation time for the drawable.
      Parameters:
      time - Animation time value
    • increaseSpeed

      public void increaseSpeed(float extraSpeed)
      Increases the object's speed by a value.
      Parameters:
      extraSpeed - Speed increment
    • multiplySpeed

      public void multiplySpeed(float multiplier)
      Multiplies the speed multiplier.
      Parameters:
      multiplier - Multiplier value
    • nextPosition

      public com.badlogic.gdx.math.Vector2 nextPosition(float deltaTime)
      Calculates next position based on current velocity.
      Parameters:
      deltaTime - Time delta for movement
      Returns:
      Predicted position
    • move

      public void move(float deltaTime)
      Moves the object by its velocity over time.
      Parameters:
      deltaTime - Time delta for movement
    • updateAnimation

      public void updateAnimation(float delta)
      Updates animation state and bounds.
      Parameters:
      delta - Time since last update
    • changeAnimation

      public void changeAnimation(AnimationType animationType)
      Changes the current animation.
      Parameters:
      animationType - New animation type
    • animate

      public void animate(com.badlogic.gdx.graphics.g2d.Batch batch)
      Renders the object using its drawable or texture.
      Parameters:
      batch - Sprite batch for rendering
    • getDrawable

      public Drawable getDrawable()
      Gets the drawable component.
      Returns:
      Drawable instance
    • getVelocity

      public com.badlogic.gdx.math.Vector2 getVelocity()
      Gets the object's velocity vector.
      Returns:
      Velocity vector