Package cl.cromer.azaraka.object
Class Object
- java.lang.Object
-
- cl.cromer.azaraka.object.Object
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
-
Fields inherited from interface cl.cromer.azaraka.Constants
AI_HEURISTIC, APPEND_LOGS, CELL_PIXELS, CHESTS, ENEMIES, ENEMY_AI, EXPORT_SCENE, FONT, FONT_SIZE, GENERATE_SCENE, GLOBAL_LOG, HORIZONTAL_CELLS, LOG_TO_FILE, OBSTACLES, PLAYER_AI, PRETTY_JSON, TITLE, VERTICAL_CELLS, VOLUME
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
changeDirection(Animation.Direction direction)
Change the direction of the object spritevoid
drawAnimation(java.awt.Graphics graphics, int x, int y)
Draw the animation on the canvasprotected boolean
getActive()
Get the active state of the GameObjectAnimation
getAnimation()
Get the current animationCell
getCell()
Get the cell the object is inprotected java.util.logging.Logger
getLogger()
Get the loggerprotected Scene
getScene()
Get the scene the object is inprotected int
getX()
Get the x position of the objectprotected int
getY()
Gets the y position of the objectprotected void
loadCharacter(java.lang.String path, int character)
Load the character animationprotected boolean
moveDown()
Move the object down one cellprotected boolean
moveLeft()
Move the object left one cellprotected boolean
moveRight()
Move the object right one cellprotected boolean
moveUp()
Move the object up one cellvoid
run()
The run methodvoid
setActive(boolean active)
Set the active state for the GameObject loopprotected void
setAnimation(Animation animation)
Set a new animationvoid
setCell(Cell cell)
Get the cell the object is inprotected void
setLogger(java.util.logging.Logger logger)
Set the loggerprotected void
setUseOffset(boolean useOffset)
Set the use offset for animationprotected void
setXScale(int x)
Scale the image to x pixelsprotected void
setYScale(int y)
Scale the image to y pixels-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
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 imagecharacter
- 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 tox
- The x coordinate to draw toy
- 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 interfacejava.lang.Runnable
-
-