Class BigAsteroid

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
GamePiece
BigAsteroid
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
MediumAsteroid, SmallAsteroid

public class BigAsteroid
extends GamePiece
BigAsteroid.java - A class to represent a large asteroid
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from class javax.swing.JComponent

    javax.swing.JComponent.AccessibleJComponent

    Nested classes/interfaces inherited from class java.awt.Container

    java.awt.Container.AccessibleAWTContainer

    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
  • Field Summary

    Fields inherited from class javax.swing.JComponent

    listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW

    Fields inherited from class java.awt.Component

    accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

    Fields inherited from interface java.awt.image.ImageObserver

    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
  • Constructor Summary

    Constructors 
    Constructor Description
    BigAsteroid()
    No-args Constructor sets direction of movement and image to random value This constructor is meant to be called by subclasses to inherit direction
    BigAsteroid​(double x, double y)
    Full Constructor sets location of asteroid
  • Method Summary

    Modifier and Type Method Description
    void destroy()
    Destroys object
    boolean equals​(java.lang.Object another)
    Compares this object to another
    double[] getCenter()
    Returns center of object
    double getDirection()
    Returns direction of trave;
    double getMaskRadius()
    Returns the radius of collision mask
    double getSpeed()
    Returns speed
    boolean isEnabled()
    Returns if object is enabled
    void move()
    Move object based on direction and speed
    void paintComponent​(java.awt.Graphics g)
    Paints asteroid on graphics canvas
    void rotateImage()
    Rotates the sprite image
    void screenWrap()
    Wraps bullet around screen if it exceeds game window boundaries
    void setDirection​(double direction)
    Sets direction
    void setSpeed​(double speed)
    Sets speed
    void tick()
    Update object every frame
    java.lang.String toString()  
    double x()
    Returns x coordinate
    void xSet​(double x)
    Sets x coordinate
    double y()
    Returns y coordinate
    void ySet​(double y)
    Sets y coordinate

    Methods inherited from class javax.swing.JComponent

    addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI

    Methods inherited from class java.awt.Container

    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree

    Methods inherited from class java.awt.Component

    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BigAsteroid

      public BigAsteroid()
      No-args Constructor sets direction of movement and image to random value This constructor is meant to be called by subclasses to inherit direction
    • BigAsteroid

      public BigAsteroid​(double x, double y)
      Full Constructor sets location of asteroid
      Parameters:
      x - x-coordinate for asteroid location
      y - y-coordinate for asteriod location
  • Method Details

    • xSet

      public void xSet​(double x)
      Sets x coordinate
      Parameters:
      x - x coordinate
    • ySet

      public void ySet​(double y)
      Sets y coordinate
      Parameters:
      y - y coordinate
    • x

      public double x()
      Returns x coordinate
      Returns:
      x coordinate
    • y

      public double y()
      Returns y coordinate
      Returns:
      y coordinate
    • setDirection

      public void setDirection​(double direction)
      Sets direction
      Parameters:
      direction - New direction of travel
    • getDirection

      public double getDirection()
      Returns direction of trave;
      Returns:
      Direction of travel
    • setSpeed

      public void setSpeed​(double speed)
      Sets speed
      Parameters:
      speed - New speed
    • getSpeed

      public double getSpeed()
      Returns speed
      Returns:
      Object speed
    • paintComponent

      public void paintComponent​(java.awt.Graphics g)
      Paints asteroid on graphics canvas
      Overrides:
      paintComponent in class javax.swing.JComponent
      Parameters:
      g - Graphics canvas to paint on
    • tick

      public void tick()
      Update object every frame
      Specified by:
      tick in class GamePiece
    • isEnabled

      public boolean isEnabled()
      Returns if object is enabled
      Overrides:
      isEnabled in class java.awt.Component
      Returns:
      true if object is enabled
    • rotateImage

      public void rotateImage()
      Rotates the sprite image
    • move

      public void move()
      Move object based on direction and speed
      Specified by:
      move in class GamePiece
    • screenWrap

      public void screenWrap()
      Wraps bullet around screen if it exceeds game window boundaries
    • destroy

      public void destroy()
      Destroys object
      Specified by:
      destroy in class GamePiece
    • getMaskRadius

      public double getMaskRadius()
      Returns the radius of collision mask
      Specified by:
      getMaskRadius in class GamePiece
      Returns:
      Radius of collision mask
    • getCenter

      public double[] getCenter()
      Returns center of object
      Specified by:
      getCenter in class GamePiece
      Returns:
      double array representing object center
    • equals

      public boolean equals​(java.lang.Object another)
      Compares this object to another
      Overrides:
      equals in class java.lang.Object
      Parameters:
      another - Object to be compared
      Returns:
      true if objects are equal
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.awt.Component