Class 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.Canvas

        java.awt.Canvas.AccessibleAWTCanvas
      • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      Canvas​(Azaraka azaraka, int width, int height)
      Initialize the canvas
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void gameOver()
      The player died, game over
      java.util.List<Chest> getChests()
      Get a list of the chests that exist
      boolean getGameStatus()
      Check if the game has ended or not
      java.util.List<Key> getKeys()
      Get a list of the keys that exist
      int getLeftMargin()
      Get the left margin being used
      Player getPlayer()
      Get the player
      Portal getPortal()
      Get the portal
      int getTopMargin()
      Get the top margin being used
      float getVolume()
      Get the current volume
      void paint​(java.awt.Graphics g)
      Override the paint method of Canvas to paint all the scene components
      void update​(java.awt.Graphics g)
      Override the update method of Canvas to update using a double buffer
      void 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
    • Constructor Detail

      • Canvas

        public Canvas​(Azaraka azaraka,
                      int width,
                      int height)
        Initialize the canvas
        Parameters:
        azaraka - The main window
        width - The width to set the canvas
        height - 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 class java.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 class java.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