Class MovableEntity
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.Renderable
-
- com.bombinggames.wurfelengine.core.gameobjects.AbstractGameObject
-
- com.bombinggames.wurfelengine.core.gameobjects.AbstractEntity
-
- com.bombinggames.wurfelengine.core.gameobjects.MovableEntity
-
- Direct Known Subclasses:
BenchmarkBall
,Bullet
,DestructionParticle
,Particle
,UserControlledShooter
public class MovableEntity extends AbstractEntity
A clas used mainly for characters or object which can walk around. To control the character you should use aControllable
or modify the movemnet viasetMovement(com.badlogic.gdx.math.Vector3)
.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.bombinggames.wurfelengine.core.gameobjects.AbstractEntity
colissionRadius
-
Fields inherited from class com.bombinggames.wurfelengine.core.gameobjects.AbstractGameObject
sprite
-
-
Constructor Summary
Constructors Constructor Description MovableEntity(byte id)
Simple MovableEntity with no animation.MovableEntity(byte id, int spritesPerDir)
Constructor of MovableEntity.MovableEntity(MovableEntity entity)
copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMovement(float x, float y, float z)
Adds speed and direction.void
addMovement(com.badlogic.gdx.math.Vector2 movement)
Adds speed and direction.void
addMovement(com.badlogic.gdx.math.Vector3 movement)
Adds speed and direction.void
addToHor(float speed)
Adds speed to horizontal moving directio.boolean
collidesWithWorld(Point pos, float colissionRadius)
check for horizontal colission (x and y)
O(1)void
dispose()
Deletes the object from the map and every other container.com.badlogic.gdx.math.Vector3
getAiming()
Defines the direction of the gun - if no gun available - the direction of the head.float
getFriction()
The factor which slows donw movement.com.badlogic.gdx.math.Vector3
getMovement()
Get the movement vector as the product of direction and speed.com.badlogic.gdx.math.Vector2
getMovementHor()
Get the movement vector as the product of direction and speed.com.badlogic.gdx.math.Vector2
getOrientation()
Direction of movement.float
getSpeed()
get the speed of the object in m/s.float
getSpeedHor()
get the horizontal speed of the object in m/s.boolean
handleMessage(com.badlogic.gdx.ai.msg.Telegram msg)
boolean
isColiding()
indicates whether this objects does collide with the blocksboolean
isFloating()
Is the object be affected by gravity?boolean
isInLiquid()
Is the character standing in a liquid?boolean
isOnCeil(Point pos)
Check if the top is coliding with a block.boolean
isOnGround()
Is the entity laying/standing on the ground?void
jump()
This method should define what happens when the object jumps.void
jump(float velo, boolean playSound)
Jump with a specific speed.void
pauseMovementAnimation()
Pauses the movement animation.void
playMovementAnimation()
Continues the movement animation when it was stopped before withpauseMovementAnimation()
.void
setColiding(boolean coliding)
indicates whether this objects does collide with the blocksvoid
setContinuousWalkingAnimation(float walkOnTheSpot)
Enable this to have a walking cycle even if not movingvoid
setFallingSound(java.lang.String fallingSound)
Sets the sound to be played when falling.void
setFloating(boolean floating)
Should the object be affected by gravity?void
setFriction(float friction)
Automatically slows speed down.void
setHorMovement(com.badlogic.gdx.math.Vector2 movement)
Set the horizontal movement and keeps zvoid
setJumpingSound(java.lang.String jumpingSound)
Set the value of jumpingSoundvoid
setMovement(com.badlogic.gdx.math.Vector2 movement)
Sets speed and direction combined in one vector.void
setMovement(com.badlogic.gdx.math.Vector3 movement)
Sets speed and direction values.void
setOrientation(com.badlogic.gdx.math.Vector2 orientation)
Turns an object in a different direction.void
setRunningSound(java.lang.String runningSound)
Set the sound to be played when running.void
setSpeedHorizontal(float speed)
Set the speed and only take x and y into account.void
setSpeedIncludingZ(float speed)
Set the speed.void
setStepSound1Grass(java.lang.String sound)
void
setWalkingAnimationCycling(boolean cycle)
Bounce back and forth (1,2,3,2,1,2 etc.) or cycle (1,2,3,1,2,3 etc.)void
setWalkingStepMode(boolean stepmode)
Set step mode or disable step mode. if no step mode plays animation back and forth.static void
setWaterSound(java.lang.String waterSound)
Set the value of waterSoundMovableEntity
spawn(Point point)
Add this entity to the map-> let it spawnvoid
step()
performs a step.void
update(float dt)
Updates the character.void
updateSprite()
-
Methods inherited from class com.bombinggames.wurfelengine.core.gameobjects.AbstractEntity
addComponent, collidesWith, getCollidingEntities, getCollidingEntities, getComponents, getComponents, getCoord, getCoveredBlocks, getDimensionZ, getHealth, getLightlevelB, getLightlevelG, getLightlevelR, getMass, getName, getPoint, getPosition, getRegisteredEntities, getSpriteCategory, getSpriteId, getSpriteValue, hasPosition, heal, isIndestructible, isInMemoryArea, isMarkedDS, isSavedPersistent, markAsVisitedDS, registerEngineEntities, registerEntity, removeComponent, removeFromMap, requestChunk, setDamageSounds, setDimensionZ, setHealth, setIndestructible, setLightlevel, setMass, setName, setPosition, setPosition, setSavePersistent, setSpriteCategory, setSpriteId, setSpriteValue, setUseRawDelta, shouldBeDisposed, takeDamage, useRawDelta
-
Methods inherited from class com.bombinggames.wurfelengine.core.gameobjects.AbstractGameObject
getColor, getDepth, getPixmap, getRotation, getScaling, getSprite, getSprite, getSpritesheet, getSpritesheetPath, getTextureDiffuse, getTextureNormal, isHidden, loadSheet, render, render, setColor, setCustomSpritesheet, setHidden, setRotation, setScaling, shouldBeRendered, staticDispose, updateSpriteCache
-
-
-
-
Constructor Detail
-
MovableEntity
public MovableEntity(byte id)
Simple MovableEntity with no animation.- Parameters:
id
-
-
MovableEntity
public MovableEntity(byte id, int spritesPerDir)
Constructor of MovableEntity.- Parameters:
id
-spritesPerDir
- The number of animation sprites per walking direction. if 0 then it only uses the value 0
-
MovableEntity
public MovableEntity(MovableEntity entity)
copy constructor- Parameters:
entity
-
-
-
Method Detail
-
setWaterSound
public static void setWaterSound(java.lang.String waterSound)
Set the value of waterSound- Parameters:
waterSound
- new value of waterSound
-
spawn
public MovableEntity spawn(Point point)
Description copied from class:AbstractEntity
Add this entity to the map-> let it spawn- Overrides:
spawn
in classAbstractEntity
- Parameters:
point
- the point in the game world where the object is. If it was previously set this is ignored.- Returns:
- returns itself
-
dispose
public void dispose()
Description copied from class:AbstractEntity
Deletes the object from the map and every other container. The opposite to spawn() but also sets a flag to remove it completely.- Overrides:
dispose
in classAbstractEntity
- See Also:
AbstractEntity.shouldBeDisposed()
,AbstractEntity.removeFromMap()
-
setWalkingAnimationCycling
public void setWalkingAnimationCycling(boolean cycle)
Bounce back and forth (1,2,3,2,1,2 etc.) or cycle (1,2,3,1,2,3 etc.)- Parameters:
cycle
- true if cycle, false if bounce
-
setContinuousWalkingAnimation
public void setContinuousWalkingAnimation(float walkOnTheSpot)
Enable this to have a walking cycle even if not moving- Parameters:
walkOnTheSpot
- the speed of the animation. Faktor without unit ~1. To disable pass 0.
-
setWalkingStepMode
public void setWalkingStepMode(boolean stepmode)
Set step mode or disable step mode. if no step mode plays animation back and forth. If step mode then some strange pattern which looks god for walking animations.- Parameters:
stepmode
- stepmode = true,
-
jump
public void jump()
This method should define what happens when the object jumps. It should call super.jump(int velo)- See Also:
jump(float, boolean)
-
jump
public void jump(float velo, boolean playSound)
Jump with a specific speed. Can jump if in air.- Parameters:
velo
- the velocity in m/splaySound
- plays jump sound if true
-
getAiming
public com.badlogic.gdx.math.Vector3 getAiming()
Defines the direction of the gun - if no gun available - the direction of the head.- Returns:
- If not overwriten returning orientation. copy save
-
update
public void update(float dt)
Updates the character. Applies gravitation.- Overrides:
update
in classAbstractEntity
- Parameters:
dt
- time since last update in ms
-
updateSprite
public void updateSprite()
-
collidesWithWorld
public boolean collidesWithWorld(Point pos, float colissionRadius)
check for horizontal colission (x and y)
O(1)- Parameters:
pos
- the new position, not modifiedcolissionRadius
-- Returns:
- true if colliding horizontal
-
isOnCeil
public boolean isOnCeil(Point pos)
Check if the top is coliding with a block. O(1)- Parameters:
pos
- the position to check- Returns:
-
setFallingSound
public void setFallingSound(java.lang.String fallingSound)
Sets the sound to be played when falling.- Parameters:
fallingSound
-
-
setRunningSound
public void setRunningSound(java.lang.String runningSound)
Set the sound to be played when running.- Parameters:
runningSound
-
-
setJumpingSound
public void setJumpingSound(java.lang.String jumpingSound)
Set the value of jumpingSound- Parameters:
jumpingSound
- new value of jumpingSound
-
setStepSound1Grass
public void setStepSound1Grass(java.lang.String sound)
- Parameters:
sound
-
-
getOrientation
public final com.badlogic.gdx.math.Vector2 getOrientation()
Direction of movement. Normalized.- Returns:
- unit vector for x and y component. copy safe
-
getMovement
public final com.badlogic.gdx.math.Vector3 getMovement()
Get the movement vector as the product of direction and speed. Don't use this method to change values. UsesetMovement(Vector3)
.- Returns:
- in m/s. returns reference
-
getMovementHor
public final com.badlogic.gdx.math.Vector2 getMovementHor()
Get the movement vector as the product of direction and speed.- Returns:
- in m/s. copy safe
-
setMovement
public void setMovement(com.badlogic.gdx.math.Vector2 movement)
Sets speed and direction combined in one vector.- Parameters:
movement
- containing direction and speed (length) in m/s.
-
setMovement
public void setMovement(com.badlogic.gdx.math.Vector3 movement)
Sets speed and direction values.- Parameters:
movement
- containing direction and speed in m/s without the unit e.g. for 5m/s use just 5 and not 5*RenderCell.GAME_EDGELENGTH
.
-
addMovement
public void addMovement(com.badlogic.gdx.math.Vector2 movement)
Adds speed and direction.- Parameters:
movement
- containing direction and speed in m/s without the unit e.g. for 5m/s use just 5 and not 5*RenderCell.GAME_EDGELENGTH
.
-
addMovement
public void addMovement(com.badlogic.gdx.math.Vector3 movement)
Adds speed and direction.- Parameters:
movement
- containing direction and speed in m/s without the unit e.g. for 5m/s use just 5 and not 5*RenderCell.GAME_EDGELENGTH
.
-
addMovement
public void addMovement(float x, float y, float z)
Adds speed and direction.- Parameters:
x
-y
-z
-
-
addToHor
public void addToHor(float speed)
Adds speed to horizontal moving directio.- Parameters:
speed
- speed in m/s without the unit so no "5*RenderCell.GAME_EDGELENGTH
" for 5 m/s but just "5".
-
setHorMovement
public void setHorMovement(com.badlogic.gdx.math.Vector2 movement)
Set the horizontal movement and keeps z- Parameters:
movement
-
-
setSpeedHorizontal
public void setSpeedHorizontal(float speed)
Set the speed and only take x and y into account.- Parameters:
speed
- in m/s
-
setSpeedIncludingZ
public void setSpeedIncludingZ(float speed)
Set the speed. Uses x, y and z.- Parameters:
speed
- in m/s
-
getSpeedHor
public float getSpeedHor()
get the horizontal speed of the object in m/s.- Returns:
-
getSpeed
public float getSpeed()
get the speed of the object in m/s.- Returns:
-
setOrientation
public void setOrientation(com.badlogic.gdx.math.Vector2 orientation)
Turns an object in a different direction. Keeps the momentum.- Parameters:
orientation
- the new orientation. Must be normalized.
-
isColiding
public boolean isColiding()
indicates whether this objects does collide with the blocks- Returns:
-
setColiding
public void setColiding(boolean coliding)
indicates whether this objects does collide with the blocks- Parameters:
coliding
- true if collides with environment
-
isFloating
public boolean isFloating()
Is the object be affected by gravity?- Returns:
-
setFloating
public void setFloating(boolean floating)
Should the object be affected by gravity?- Parameters:
floating
- if true then not affacted
-
isOnGround
public boolean isOnGround()
Description copied from class:AbstractEntity
Is the entity laying/standing on the ground?- Overrides:
isOnGround
in classAbstractEntity
- Returns:
- true when on the ground. False if in air or not in memory.
-
isInLiquid
public boolean isInLiquid()
Is the character standing in a liquid?- Returns:
-
getFriction
public float getFriction()
The factor which slows donw movement.- Returns:
-
setFriction
public void setFriction(float friction)
Automatically slows speed down.- Parameters:
friction
- The higher the value, the less "slide". If =0 friciton is disabled. Value should be ~0.01f
-
step
public void step()
performs a step. Plays a sound.
-
pauseMovementAnimation
public void pauseMovementAnimation()
Pauses the movement animation. A use case is when you want to play a different animation then walking while the object may still move.- See Also:
playMovementAnimation()
-
playMovementAnimation
public void playMovementAnimation()
Continues the movement animation when it was stopped before withpauseMovementAnimation()
.
-
handleMessage
public boolean handleMessage(com.badlogic.gdx.ai.msg.Telegram msg)
-
-