Package cl.cromer.azaraka
Class Canvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Canvas
-
- cl.cromer.azaraka.Canvas
-
- All Implemented Interfaces:
Constants
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public class Canvas extends java.awt.Canvas implements Constants
This class extends the canvas to make drawing and listening easier- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from interface cl.cromer.azaraka.Constants
Constants.AIHeuristic, Constants.LogLevel, Constants.PlayerAIType
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
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 void
gameOver()
The player died, game overjava.util.List<Chest>
getChests()
Get a list of the chests that existboolean
getGameStatus()
Check if the game has ended or notjava.util.List<Key>
getKeys()
Get a list of the keys that existint
getLeftMargin()
Get the left margin being usedPlayer
getPlayer()
Get the playerPortal
getPortal()
Get the portalint
getTopMargin()
Get the top margin being usedfloat
getVolume()
Get the current volumevoid
paint(java.awt.Graphics g)
Override the paint method of Canvas to paint all the scene componentsvoid
update(java.awt.Graphics g)
Override the update method of Canvas to update using a double buffervoid
win()
Called when the game is won-
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface cl.cromer.azaraka.Constants
getLogger, initializeLogger, random
-
-
-
-
Constructor Detail
-
Canvas
public Canvas(Azaraka azaraka, int width, int height)
Initialize the canvas- Parameters:
azaraka
- The main windowwidth
- The width to set the canvasheight
- The width to set the canvas
-
-
Method Detail
-
paint
public void paint(java.awt.Graphics g)
Override the paint method of Canvas to paint all the scene components- Overrides:
paint
in classjava.awt.Canvas
- Parameters:
g
- The graphics object to paint
-
update
public void update(java.awt.Graphics g)
Override the update method of Canvas to update using a double buffer- Overrides:
update
in classjava.awt.Canvas
- Parameters:
g
- The graphics object to paint
-
gameOver
public void gameOver()
The player died, game over
-
win
public void win()
Called when the game is won
-
getVolume
public float getVolume()
Get the current volume- Returns:
- Returns the current volume
-
getPlayer
public Player getPlayer()
Get the player- Returns:
- Returns the player object
-
getPortal
public Portal getPortal()
Get the portal- Returns:
- Returns the portal object
-
getKeys
public java.util.List<Key> getKeys()
Get a list of the keys that exist- Returns:
- Returns all the keys that are in the game
-
getChests
public java.util.List<Chest> getChests()
Get a list of the chests that exist- Returns:
- Returns all the chests that are in the game
-
getLeftMargin
public int getLeftMargin()
Get the left margin being used- Returns:
- Returns the left margin
-
getTopMargin
public int getTopMargin()
Get the top margin being used- Returns:
- Returns the top margin
-
getGameStatus
public boolean getGameStatus()
Check if the game has ended or not- Returns:
- Returns true if the game is still playing or false if game is over
-
-