Class Entity

    • Field Detail

      • sprites

        protected java.util.ArrayList<Sprite> sprites
        The entity's sprites
      • sheets

        protected java.util.ArrayList<SpriteSheet> sheets
        The entity's sprite sheets
      • boundaries

        public java.util.ArrayList<EntityBoundary> boundaries
        Collection of the entity's boundaries
      • interactions

        public java.util.ArrayList<EntityEntityInteraction> interactions
        Collection of the entity's interactions
      • sprite

        public Sprite sprite
        The sprite to use while rendering
      • image

        protected org.newdawn.slick.Image image
        The buffered image to use when rendering (default)
      • firstLayer

        protected org.newdawn.slick.Image firstLayer
        If isDualRendered is true, render this before the player ("below")
      • secondLayer

        protected org.newdawn.slick.Image secondLayer
        If isDualRendered is true, render this after the player ("above")
      • lastCollision

        public EntityEntityCollision lastCollision
        The most recent collision that has occurred for the entity. If no collisions have occurred within the entity's lifetime, this will be null
      • lastCollisionEvent

        public EntityEntityCollisionEvent lastCollisionEvent
        The most recent collision event to have occurred. This will be null if no collision event has yet to take place
      • defaultBoundary

        public EntityBoundary defaultBoundary
        The boundary to use if not specified
      • deltaX

        public double deltaX
        Less-than-one change in the x-coordinate, used for non-integer speeds
      • deltaY

        public double deltaY
        Less-than-one change in the y-coordinate, used for non-integer speeds
      • speed

        public double speed
        The entity's speed (magnitude of its location change when moving)
      • uuid

        public int uuid
        The entity's unique identification number. Use name for user-friendly identification
      • health

        public int health
        Amount of damage the entity can take before dying
      • maximumHealth

        public int maximumHealth
        Maximum amount of health the entity can have
      • isAnimated

        public boolean isAnimated
        Whether or not the entity is animated
      • isTraversable

        public boolean isTraversable
        Whether or not other entities, mainly the player, can walk over it or not
      • isCollided

        public boolean isCollided
        Whether or not the entity is currently collided with another entity
      • canCollide

        public boolean canCollide
        Whether or not the entity is "allowed" to collide with others
      • isMovingUpwards

        protected boolean isMovingUpwards
        Whether or not the entity is currently moving upwards
      • isMovingDownwards

        protected boolean isMovingDownwards
        Whether or not the entity is currently moving downwards
      • isMovingLeftwards

        protected boolean isMovingLeftwards
        Whether or not the entity is currently moving leftwards
      • isMovingRightwards

        protected boolean isMovingRightwards
        Whether or not the entity is currently moving rightwards
      • isAllowedToMoveUpwards

        public boolean isAllowedToMoveUpwards
        Whether or not the entity is allowed to move upwards
      • isAllowedToMoveDownwards

        public boolean isAllowedToMoveDownwards
        Whether or not the entity is allowed to move downwards
      • isAllowedToMoveLeftwards

        public boolean isAllowedToMoveLeftwards
        Whether or not the entity is allowed to move leftwards
      • isAllowedToMoveRightwards

        public boolean isAllowedToMoveRightwards
        Whether or not the entity is allowed to move rightwards
      • isSectorSpecific

        public boolean isSectorSpecific
        Whether or not the entity is "bound" to, or only exists in, a specific map sector
      • name

        public java.lang.String name
        Human-readable identifier for the entity (not unique)
      • debugFont

        private static final org.newdawn.slick.Font debugFont
      • nameTagBackgroundColor

        private static final org.newdawn.slick.Color nameTagBackgroundColor
      • healthBarColor

        private static final org.newdawn.slick.Color healthBarColor
      • nameTagWidth

        private int nameTagWidth
      • setFontMetrics

        private boolean setFontMetrics
        Whether or not font metrics have been initialized. Since render(Graphics) is called about 60 times a second, and the resulting font metrics object will always be the same, there is no need to keep re-computing it each time render(Graphics) is called
    • Constructor Detail

      • Entity

        Entity​(java.lang.String name)
      • Entity

        Entity​(java.lang.String name,
               Sprite sprite)
      • Entity

        Entity​(java.lang.String name,
               SpriteSheet sheet)
    • Method Detail

      • drawFirstLayer

        public void drawFirstLayer​(org.newdawn.slick.Graphics graphics)
        Draws the first "layer", assuming isDualRendered is true (below the player)
      • drawSecondLayer

        public void drawSecondLayer​(org.newdawn.slick.Graphics graphics)
        Draws the second "layer", assuming isDualRendered is true (above the player)
      • drawDebug

        public void drawDebug​(org.newdawn.slick.Graphics graphics)
        Renders debug information, such as the entity's boundaries and "name tag"
      • drawNameTag

        private void drawNameTag​(org.newdawn.slick.Graphics graphics)
        Draws the entity's "name tag", which is toString()
      • drawHealthBar

        private void drawHealthBar​(org.newdawn.slick.Graphics graphics)
        Shows the entity's health above them
      • drawBoundaries

        private void drawBoundaries​(org.newdawn.slick.Graphics graphics)
        Draws all of the entity's boundaries
      • tick

        public void tick()
        Ticks boundaries and interactions
        Specified by:
        tick in interface Tickable
        See Also:
      • setPosition

        public void setPosition​(int x,
                                int y)
        Sets the entity's x and y coordinates, as well as updating the coordinate deltas
        setPosition in class Renderable
        x - The new x-coordinate
        y - The new y-coordinate
        See Also:
        deltaX, deltaY
      • x

        public void x​(int x)
        x in class Renderable
      • y

        public void y​(int y)
        y in class Renderable
      • x

        public void x​(int x,
                      boolean setDelta)
      • y

        public void y​(int y,
                      boolean setDelta)
      • onSectorEnter

        public void onSectorEnter​(MapSector entering)
      • onSectorLeave

        public void onSectorLeave​(MapSector leaving)
      • move

        private void move​(byte direction,
                          EntityBoundary boundary)
        Updates the entity's location by speed, unless the specified boundary is outside of the game's window
      • isRightOf

        private boolean isRightOf​(Entity e)
        Returns whether or not the entity is to the "right" of the other entity
      • isLeftOf

        private boolean isLeftOf​(Entity e)
        Returns whether or not the entity is to the "left" of the other entity
      • isAbove

        private boolean isAbove​(Entity e)
        Returns whether or not the entity is "above" the other entity
      • isBelow

        private boolean isBelow​(Entity e)
        Returns whether or not the entity is "below" the other entity
      • setBoundaries

        protected abstract void setBoundaries()
        Sets the entity's boundaries
        See Also:
      • setCollisions

        public abstract void setCollisions()
        Sets the entity's collisions
        See Also:
      • setInteractions

        protected abstract void setInteractions()
        Sets the entity's interactions
        See Also:
      • onSpriteChanged

        private void onSpriteChanged()
      • setSprite

        public void setSprite​(int index,
                              boolean update)
        Sets the current sprite
        index - The index in sprites
        See Also:
      • setSprite

        public void setSprite​(Sprite sprite)
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object