Class Object

    • Constructor Detail

      • Object

        protected Object​(Scene scene,
                         Cell cell)
        Initialize the object
        Parameters:
        scene - The scene the object is in
        cell - The cell the object is in
    • Method Detail

      • getX

        protected int getX()
        Get the x position of the object
        Returns:
        Returns the x coordinate
      • getY

        protected int getY()
        Gets the y position of the object
        Returns:
        Returns the y coordinate
      • setXScale

        protected void setXScale​(int x)
        Scale the image to x pixels
        Parameters:
        x - The amount of pixels to scale
      • setYScale

        protected void setYScale​(int y)
        Scale the image to y pixels
        Parameters:
        y - The amount of pixels to scale
      • getScene

        protected Scene getScene()
        Get the scene the object is in
        Returns:
        Returns the scene
      • getCell

        public Cell getCell()
        Get the cell the object is in
        Returns:
        Returns the cell
      • setCell

        public void setCell​(Cell cell)
        Get the cell the object is in
        Parameters:
        cell - The cell
      • getAnimation

        public Animation getAnimation()
        Get the current animation
        Returns:
        Returns an animation
      • setAnimation

        protected void setAnimation​(Animation animation)
        Set a new animation
        Parameters:
        animation - The new animation
      • setUseOffset

        protected void setUseOffset​(boolean useOffset)
        Set the use offset for animation
        Parameters:
        useOffset - If true the animation will use an offset to help center it
      • loadCharacter

        protected void loadCharacter​(java.lang.String path,
                                     int character)
        Load the character animation
        Parameters:
        path - The path to the image
        character - The character number
      • drawAnimation

        public void drawAnimation​(java.awt.Graphics graphics,
                                  int x,
                                  int y)
        Draw the animation on the canvas
        Parameters:
        graphics - The graphics object to draw to
        x - The x coordinate to draw to
        y - The y coordinate to draw to
      • moveUp

        protected boolean moveUp()
        Move the object up one cell
        Returns:
        Returns true if it was moved
      • moveDown

        protected boolean moveDown()
        Move the object down one cell
        Returns:
        Returns true if it was moved
      • moveLeft

        protected boolean moveLeft()
        Move the object left one cell
        Returns:
        Returns true if it was moved
      • moveRight

        protected boolean moveRight()
        Move the object right one cell
        Returns:
        Returns true if it was moved
      • changeDirection

        protected boolean changeDirection​(Animation.Direction direction)
        Change the direction of the object sprite
        Parameters:
        direction - The new direction
        Returns:
        Returns true if a direction change is not necessary
      • getLogger

        protected java.util.logging.Logger getLogger()
        Get the logger
        Returns:
        Returns a logger
      • setLogger

        protected void setLogger​(java.util.logging.Logger logger)
        Set the logger
        Parameters:
        logger - The logger to set
      • getActive

        protected boolean getActive()
        Get the active state of the GameObject
        Returns:
        Returns true if the object is active or false otherwise
      • setActive

        public void setActive​(boolean active)
        Set the active state for the GameObject loop
        Parameters:
        active - Set to true to have the run method loop run indefinitely or false to stop the loop
      • run

        public void run()
        The run method
        Specified by:
        run in interface java.lang.Runnable