Package de.tum.cit.fop.maze.objects
Class GameObject
java.lang.Object
de.tum.cit.fop.maze.objects.GameObject
Base class for all game objects with position, movement, and animation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.badlogic.gdx.math.Rectangleprotected AnimationTypeprotected Drawablecom.badlogic.gdx.math.Vector2protected com.badlogic.gdx.math.Vector2floatprotected floatprotected com.badlogic.gdx.math.Vector2protected com.badlogic.gdx.graphics.g2d.TextureRegioncom.badlogic.gdx.math.Vector2 -
Constructor Summary
ConstructorsConstructorDescriptionGameObject(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 TypeMethodDescriptionvoidanimate(com.badlogic.gdx.graphics.g2d.Batch batch) Renders the object using its drawable or texture.voidchangeAnimation(AnimationType animationType) Changes the current animation.static BooleanentitiesOverlap(GameObject gameObject1, GameObject gameObject2) Checks if two game objects overlap.com.badlogic.gdx.math.RectangleGets the object's collision bounds.Gets the drawable component.com.badlogic.gdx.math.Vector2getSize()Gets the object's hitbox size.floatgetSpeed()Gets the object's current speed including modifiers.com.badlogic.gdx.math.Vector2Gets the object's velocity vector.voidincreaseSpeed(float extraSpeed) Increases the object's speed by a value.voidmove(float deltaTime) Moves the object by its velocity over time.voidmultiplySpeed(float multiplier) Multiplies the speed multiplier.com.badlogic.gdx.math.Vector2nextPosition(float deltaTime) Calculates next position based on current velocity.voidsetAnimationTime(float time) Sets the animation time for the drawable.voidupdateAnimation(float delta) Updates animation state and bounds.
-
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
-
bounds
protected com.badlogic.gdx.math.Rectangle bounds -
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
Checks if two game objects overlap.- Parameters:
gameObject1- First objectgameObject2- 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
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
Gets the drawable component.- Returns:
- Drawable instance
-
getVelocity
public com.badlogic.gdx.math.Vector2 getVelocity()Gets the object's velocity vector.- Returns:
- Velocity vector
-