Class AbstractGameObject

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    AbstractEntity, RenderCell


    public abstract class AbstractGameObject
    extends com.badlogic.gdx.graphics.g3d.Renderable
    implements java.io.Serializable
    An AbstractGameObject is something wich can be found in the game world.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected GameSpaceSprite sprite
      caching the sprite for rendering
      • Fields inherited from class com.badlogic.gdx.graphics.g3d.Renderable

        bones, environment, material, meshPart, shader, userData, worldTransform
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractGameObject​()
      Creates an object.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      com.badlogic.gdx.graphics.Color getColor​()
      get the tint of the object.
      abstract Coordinate getCoord​()
      not copy save
      float getDepth​()
      Returns the depth of the object.
      abstract int getDimensionZ​()
      The height of the object for depth sorting.
      abstract float getLightlevelB​()
      How bright is the object?
      abstract float getLightlevelG​()
      How bright is the object?
      abstract float getLightlevelR​()
      How bright is the object?
      abstract java.lang.String getName​()
      Returns the name of the object
      static com.badlogic.gdx.graphics.Pixmap getPixmap​()  
      abstract Point getPoint​()
      Can be internal reference or shared object.
      abstract Position getPosition​()
      Return the coordinates of the object in the game world.
      float getRotation​()
      Returns the rotation of the object.
      float getScaling​()
      Returns the scale factor of the object.
      GameSpaceSprite getSprite​()  
      static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getSprite​(char category, byte id, byte value)
      Returns a sprite texture.
      abstract char getSpriteCategory​()
      Get the category letter for accessing sprites.
      abstract byte getSpriteId​()
      the id of the sprite using for rendering.
      By default is the same as the block id but in some cases some objects share one sprite so they can have the same id.
      static com.badlogic.gdx.graphics.g2d.TextureAtlas getSpritesheet​()
      Returns the spritesheet used for rendering.
      static java.lang.String getSpritesheetPath​()
      path of the spritesheet
      abstract byte getSpriteValue​()
      Get the value.
      static com.badlogic.gdx.graphics.Texture getTextureDiffuse​()
      the diffuse map
      static com.badlogic.gdx.graphics.Texture getTextureNormal​()
      the normal map
      boolean isHidden​()
      Returns true, when set as hidden.
      static void loadSheet​()
      Load the spritesheet from memory.
      void render​(GameView view)
      Draws an object if it is not hidden and not clipped.
      void render​(GameView view, int xPos, int yPos)
      Renders at a custom position in projection space. uses heap
      void setColor​(com.badlogic.gdx.graphics.Color color)
      Give the object a tint.
      static void setCustomSpritesheet​(java.lang.String customPath)
      Set your custom spritesheet path. the suffix will be added
      void setHidden​(boolean hidden)
      Hides an object.
      abstract void setLightlevel​(float lightlevel)
      Set the brightness of the object.
      abstract void setPosition​(Position pos)
      Set the coordinates without safety check.
      void setRotation​(float rotation)  
      void setScaling​(float scaling)
      Absolute scaling factor.
      boolean shouldBeRendered​(Camera camera)
      Gives information if object should be rendered.
      static void staticDispose​()
      disposes static fields
      void updateSpriteCache​()
      Updates the saved vertex data with the engine default configuration (category, sprite id and sprite value).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from class com.badlogic.gdx.graphics.g3d.Renderable

        set
    • Field Detail

      • sprite

        protected transient GameSpaceSprite sprite
        caching the sprite for rendering
    • Constructor Detail

      • AbstractGameObject

        protected AbstractGameObject​()
        Creates an object.
    • Method Detail

      • staticDispose

        public static void staticDispose​()
        disposes static fields
      • getTextureDiffuse

        public static com.badlogic.gdx.graphics.Texture getTextureDiffuse​()
        the diffuse map
        Returns:
      • getTextureNormal

        public static com.badlogic.gdx.graphics.Texture getTextureNormal​()
        the normal map
        Returns:
      • getPixmap

        public static com.badlogic.gdx.graphics.Pixmap getPixmap​()
        Returns:
        can be null if pixmap loadin is disabled
      • setCustomSpritesheet

        public static void setCustomSpritesheet​(java.lang.String customPath)
        Set your custom spritesheet path. the suffix will be added
        Parameters:
        customPath - format like "com/bombinggames/wurfelengine/core/images/Spritesheet" without suffix
      • getSpritesheetPath

        public static java.lang.String getSpritesheetPath​()
        path of the spritesheet
        Returns:
      • loadSheet

        public static void loadSheet​()
                              throws java.io.FileNotFoundException
        Load the spritesheet from memory.
        Throws:
        java.io.FileNotFoundException
      • getSprite

        public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getSprite​(char category,
                                                                                       byte id,
                                                                                       byte value)
        Returns a sprite texture.
        Parameters:
        category - the category of the sprite e.g. 'b' for blocks
        id - the id of the object
        value - the value of the object
        Returns:
      • getSpritesheet

        public static com.badlogic.gdx.graphics.g2d.TextureAtlas getSpritesheet​()
        Returns the spritesheet used for rendering.
        Returns:
        the spritesheet used by the objects
      • getSpriteCategory

        public abstract char getSpriteCategory​()
        Get the category letter for accessing sprites.
        Returns:
      • getDimensionZ

        public abstract int getDimensionZ​()
        The height of the object for depth sorting.
        Returns:
        game space
      • setPosition

        public abstract void setPosition​(Position pos)
        Set the coordinates without safety check. May use different object pointing to the same position.
        Parameters:
        pos - the coordinates you want to set
      • getLightlevelR

        public abstract float getLightlevelR​()
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Returns:
        1 is default bright. 0 is black.
      • getLightlevelG

        public abstract float getLightlevelG​()
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Returns:
        1 is default bright. 0 is black.
      • getLightlevelB

        public abstract float getLightlevelB​()
        How bright is the object? The lightlevel is a scale applied to the color. 1 is default value.
        Returns:
        1 is default bright. 0 is black.
      • setLightlevel

        public abstract void setLightlevel​(float lightlevel)
        Set the brightness of the object. The lightlevel is a scaling factor. 1 is default value.
        Parameters:
        lightlevel - 1 is default bright. 0 is black.
      • getPosition

        public abstract Position getPosition​()
        Return the coordinates of the object in the game world. Not copy safe as it points to the interaly used object.
        Returns:
        Reference to the position object which points to the location in the game world.
        See Also:
        getPoint()
      • getPoint

        public abstract Point getPoint​()
        Can be internal reference or shared object.
        Returns:
        See Also:
        getPosition()
      • getDepth

        public float getDepth​()
        Returns the depth of the object. The depth is the game world space projected on one axis orthogonal to the camera's angle. Objects nearer to camera have a bigger value.
        Returns:
        distance from zero level
      • render

        public void render​(GameView view)
        Draws an object if it is not hidden and not clipped. in game space
        Parameters:
        view -
      • render

        public void render​(GameView view,
                           int xPos,
                           int yPos)
        Renders at a custom position in projection space. uses heap
        Parameters:
        view -
        xPos - rendering position, center of sprite in projection space
        yPos - rendering position, center of sprite in projection space
      • updateSpriteCache

        public void updateSpriteCache​()
        Updates the saved vertex data with the engine default configuration (category, sprite id and sprite value).
      • getSpriteId

        public abstract byte getSpriteId​()
        the id of the sprite using for rendering.
        By default is the same as the block id but in some cases some objects share one sprite so they can have the same id.
        Returns:
        in range [0;RenderCell.OBJECTTYPESNUM].
      • getSpriteValue

        public abstract byte getSpriteValue​()
        Get the value. It is like a sub-id and can identify the status.
        Returns:
        in range [0;RenderCell.VALUESNUM]. Is -1 if about to destroyed.
      • getName

        public abstract java.lang.String getName​()
        Returns the name of the object
        Returns:
        the name of the object
      • getRotation

        public float getRotation​()
        Returns the rotation of the object.
        Returns:
        in degrees
      • getScaling

        public float getScaling​()
        Returns the scale factor of the object.
        Returns:
        1 is no scaling
      • isHidden

        public boolean isHidden​()
        Returns true, when set as hidden. Hidden objects are not rendered even when they are clipped ("clipped" by the meaning of the raytracing).
        Returns:
        if the object is invisible
      • setHidden

        public void setHidden​(boolean hidden)
        Hides an object. It won't be rendered but still affects physics.
        Parameters:
        hidden -
      • setRotation

        public void setRotation​(float rotation)
        Parameters:
        rotation - set the rotation in degrees.
      • setScaling

        public void setScaling​(float scaling)
        Absolute scaling factor.
        Parameters:
        scaling - 1 no scaling, > bigger, < 1 smaller
      • setColor

        public void setColor​(com.badlogic.gdx.graphics.Color color)
        Give the object a tint. The default brightness is RGBA 0x808080FF so you can make it brighter and darker by modifying R, G and B.
        Parameters:
        color - refence is kept
      • getColor

        public com.badlogic.gdx.graphics.Color getColor​()
        get the tint of the object. The default brightness is RGBA 0x808080FF so you can make it brighter and darker by modifying R, G and B.
        Returns:
        not copy safe, not null
      • getSprite

        public GameSpaceSprite getSprite​()
        Returns:
        the sprite used for rendering
      • shouldBeRendered

        public boolean shouldBeRendered​(Camera camera)
        Gives information if object should be rendered.
        Parameters:
        camera -
        Returns: