Class MovableEntity

    • 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 class AbstractEntity
        Parameters:
        point - the point in the game world where the object is. If it was previously set this is ignored.
        Returns:
        returns itself
      • 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/s
        playSound - 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 class AbstractEntity
        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 modified
        colissionRadius -
        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. Use setMovement(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 class AbstractEntity
        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 with pauseMovementAnimation().
      • handleMessage

        public boolean handleMessage​(com.badlogic.gdx.ai.msg.Telegram msg)