|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
Sector
Nested Class Summary | |
(package private) class |
Sector.keyboardHandler
|
(package private) class |
Sector.sizeChangeListener
|
Nested classes inherited from class java.awt.Canvas |
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
(package private) java.lang.Thread |
animatorThread
|
(package private) int |
delay
|
(package private) java.util.ArrayList |
inSector
|
(package private) java.util.ArrayList |
obstacles
|
(package private) java.awt.Dimension |
offDimension
|
(package private) java.awt.Graphics |
offGraphics
|
(package private) java.awt.Image |
offImage
|
private int |
ownPort
|
(package private) OwnSpaceCraft |
ownShip
|
(package private) static java.util.Random |
rand
|
(package private) int |
sizeX
|
(package private) int |
sizeY
|
(package private) java.awt.Point[] |
starPositions
|
(package private) Obstacle |
x
|
Fields inherited from class java.awt.Canvas |
|
Fields inherited from class java.awt.Component |
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 | |
Sector(int ownPort)
Default constructor. |
|
Sector(int ownPort,
int fps)
Initializes the drawing canvas. |
Method Summary | |
void |
addObstacle(Obstacle obs)
Add a single obstacle to those in the sector. |
SpaceCraft |
collisionCheck()
Checks for a collision between the users spacecraft and all aliens in the sector. |
OwnSpaceCraft |
createOwnSpaceCraft()
Creates a space craft for the user in a random position with a random heading. |
void |
createStars()
Creates stars in random positions for the display |
void |
drawAllSpaceCraft(java.awt.Graphics g)
Draws all alien space craft in the sector. |
void |
drawObstacles(java.awt.Graphics g)
Draws all obstacles in the sector. |
void |
drawStars(java.awt.Graphics g)
Renders all the stars in the sector. |
static void |
main(java.lang.String[] args)
main for testing the Sector class. |
boolean |
obstacleClear()
Check to see if an obstacle is in front of ownShip. |
void |
paint(java.awt.Graphics g)
Override of the paint method for double buffering. |
void |
removeSpaceCraft(SpaceCraft craft)
Remove a SpaceCraft from the sector. |
void |
run()
Animation thread. |
void |
update(java.awt.Graphics g)
Renders all object in the sector to the back buffer and then swaps buffers. |
void |
updateAndAddSpaceCraft(SpaceCraft craft)
If the input parameter SpaceCraft is already in the sector its heading and/or postion are updated. |
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, getAlignmentX, getAlignmentY, getBackground, 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, getMouseWheelListeners, getName, getParent, getPeer, 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, isOpaque, 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, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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 |
Field Detail |
java.util.ArrayList inSector
java.util.ArrayList obstacles
OwnSpaceCraft ownShip
java.awt.Image offImage
java.awt.Graphics offGraphics
java.awt.Dimension offDimension
int delay
java.lang.Thread animatorThread
int sizeX
int sizeY
static java.util.Random rand
java.awt.Point[] starPositions
Obstacle x
private int ownPort
Constructor Detail |
public Sector(int ownPort)
public Sector(int ownPort, int fps)
fps
- number of frames to be rendered per secondMethod Detail |
public SpaceCraft collisionCheck()
public void updateAndAddSpaceCraft(SpaceCraft craft)
craft
- to be undated or addedpublic boolean obstacleClear()
public void addObstacle(Obstacle obs)
obs
- obstacle to be added to the scenepublic void removeSpaceCraft(SpaceCraft craft)
craft
- SpaceCraft to be removed.public void createStars()
public void drawStars(java.awt.Graphics g)
g
- Graphics context for renderingpublic void run()
run
in interface java.lang.Runnable
public void paint(java.awt.Graphics g)
public void update(java.awt.Graphics g)
public void drawAllSpaceCraft(java.awt.Graphics g)
g
- Graphics context for renderingpublic void drawObstacles(java.awt.Graphics g)
g
- Graphics context for renderingpublic OwnSpaceCraft createOwnSpaceCraft()
public static void main(java.lang.String[] args)
args
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |