|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--Asteroids
Asteroids code can be used for an applet or an applciation. This works because an Applet is a panel.
Inner classes inherited from class java.awt.Component |
java.awt.Component.AWTTreeLock |
Field Summary | |
(package private) AsteroidsGame |
asteroidsgame
The game object that holds all of our sprites. |
(package private) static java.awt.Color |
backgroundcolor
Background color. |
(package private) static java.applet.AudioClip |
crashSound
Sound clip for ship hitting an asteroid. |
(package private) java.lang.String |
currentsoundfilename
|
(package private) boolean |
detail
A flag used to toggle more detail in the image. |
(package private) static java.applet.AudioClip |
explosionSound
Sound clip for bullet blowing up an asteroid, missile, or Ufo. |
(package private) static java.applet.AudioClip |
fireSound
Sound clip for ship shooting a bullet. |
(package private) java.awt.Font |
font
The font to use onscreen. |
(package private) int |
fontHeight
|
(package private) java.awt.FontMetrics |
fontmetric
|
(package private) int |
fontWidth
|
(package private) static java.awt.Color |
foregroundcolor
Foreground color. |
(package private) static java.lang.Thread |
loadThread
This thread is for loading the sounds. |
(package private) static java.lang.Thread |
loopThread
This thread is for driving the simulation updates. |
(package private) static java.applet.AudioClip |
missileSound
Sound clip for the missile moving. |
(package private) java.awt.Dimension |
offDimension
Size of the offscreen buffer. |
(package private) java.awt.Graphics |
offGraphics
Graphics of the offscreen buffer. |
(package private) java.awt.Image |
offImage
Image of the offscreen buffer. |
(package private) static Randomizer |
randomizer
Use this to randomize everybody's settings. |
(package private) static RealPixelConverter |
realpixelconverter
Use this to convert between the real coordinates of the Sprite shape polygons and the pixel-sized coordinates used in the shapetransform by the draw function. |
(package private) static java.applet.AudioClip |
saucerSound
Sound clip for the Ufo moving. |
(package private) static boolean |
soundflag
A mute flag user can use to turn sound on and off. |
(package private) static boolean |
soundsloaded
Use this flag to signal if you successfully loaded the sounds. |
(package private) static int |
START_PIXELHEIGHT
Intended size of the start window. |
(package private) static int |
START_PIXELWIDTH
Intended size of the start window. |
(package private) static java.applet.AudioClip |
thrustersSound
Sound clip for the ship's thrusters firing. |
private double |
timestep
Use this to time how long the updates take. |
(package private) static boolean |
triedgettingsounds
Leave this flag off until you've finished trying to load the sound. |
(package private) boolean |
trueapplet
Flag for whether this is being run as a true applet or simply as an application. |
(package private) static java.applet.AudioClip |
warpSound
Sound clip for the hyperspace jump. |
Fields inherited from class java.applet.Applet |
serialVersionUID,
stub |
Fields inherited from class java.awt.Panel |
base,
nameCounter,
serialVersionUID |
Fields inherited from class java.awt.Container |
component,
containerListener,
containerSerializedDataVersion,
dispatcher,
layoutMgr,
maxSize,
ncomponents,
serialVersionUID |
Fields inherited from class java.awt.Component |
actionListenerK,
adjustmentListenerK,
appContext,
assert,
background,
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
changeSupport,
componentListener,
componentListenerK,
componentOrientation,
componentSerializedDataVersion,
containerListenerK,
cursor,
dropTarget,
enabled,
eventMask,
focusListener,
focusListenerK,
font,
foreground,
hasFocus,
height,
incRate,
inputMethodListener,
inputMethodListenerK,
isInc,
isPacked,
itemListenerK,
keyListener,
keyListenerK,
LEFT_ALIGNMENT,
locale,
LOCK,
minSize,
mouseListener,
mouseListenerK,
mouseMotionListener,
mouseMotionListenerK,
name,
nameExplicitlySet,
newEventsOnly,
ownedWindowK,
parent,
peer,
peerFont,
popups,
prefSize,
RIGHT_ALIGNMENT,
serialVersionUID,
textListenerK,
TOP_ALIGNMENT,
valid,
visible,
width,
windowListenerK,
x,
y |
Constructor Summary | |
Asteroids()
|
Method Summary | |
java.lang.String |
getAppletInfo()
|
(package private) double |
heightpixel()
Accessor to the current pixel dimensions of the view. |
void |
init()
Init does the work of a constructor: it creates a new AsteroidsGame. |
boolean |
isFocusTraversable()
In order for the panel to be able to get focus so it can use its KeyListener, I have to do this overload. |
boolean |
keyDown(java.awt.Event e,
int key)
Call the ship.keyPressed method and let the ship use the arrow keys, the spacebar and the h key. |
boolean |
keyUp(java.awt.Event e,
int key)
Call the ship.keyPressed method and let the ship use the arrow keys, the spacebar and the h key. |
java.applet.AudioClip |
loadSound(java.lang.String soundname)
This function tries to load a soundfile and return an audioclip. |
void |
loadSounds()
This uses the loadSound(AudioClip, String) function which has pieces to comment in and out depending on the JDK being used. |
void |
paint(java.awt.Graphics g)
|
void |
run()
First use the loadThread to load the sounds, then set loadThread to null and use a while loop on loopthread to repeatedly update the sprites and call repaint. |
(package private) double |
scale()
The conversion factor used in strectching or shrinking the real length to a pixel length. |
void |
setPixelWindow(java.awt.Dimension d)
Mutator to tell the converter about a new pixel view window size. |
void |
start()
Load the sounds by starting a loadThread, also start the main loopThread. |
void |
stop()
Stop the loadThread and the loopThread by setting them to null. |
void |
update(java.awt.Graphics g)
|
(package private) double |
widthpixel()
Accessor to the current pixel dimensions of the view. |
Methods inherited from class java.applet.Applet |
destroy,
getAppletContext,
getAudioClip,
getAudioClip,
getCodeBase,
getDocumentBase,
getImage,
getImage,
getLocale,
getParameter,
getParameterInfo,
isActive,
newAudioClip,
play,
play,
resize,
resize,
setStub,
showStatus |
Methods inherited from class java.awt.Panel |
|
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
applyOrientation,
countComponents,
deliverEvent,
dispatchEventImpl,
dispatchEventToSelf,
doLayout,
eventEnabled,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents_NoClientCode,
getComponents,
getCursorTarget,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getMouseEventTarget,
getPreferredSize,
getWindow,
initIDs,
insets,
invalidate,
invalidateTree,
isAncestorOf,
layout,
lightweightPrint,
list,
list,
locate,
minimumSize,
nextFocus,
paintComponents,
paramString,
postProcessKeyEvent,
postsOldMouseEvents,
preferredSize,
preProcessKeyEvent,
print,
printComponents,
printOneComponent,
processContainerEvent,
processEvent,
proxyEnableEvents,
proxyRequestFocus,
readObject,
remove,
remove,
removeAll,
removeContainerListener,
removeNotify,
setCursor,
setFocusOwner,
setFont,
setLayout,
transferFocus,
updateCursor,
validate,
validateTree,
writeObject |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
areInputMethodsEnabled,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont_NoClientCode,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getIntrinsicCursor,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getNativeContainer,
getParent_NoClientCode,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getToolkitImpl,
getTreeLock,
getWidth,
getWindowForObject,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isEnabledImpl,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
postEvent,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
Field Detail |
static Randomizer randomizer
static java.awt.Color backgroundcolor
static java.awt.Color foregroundcolor
static java.lang.Thread loadThread
static java.lang.Thread loopThread
static boolean triedgettingsounds
static boolean soundsloaded
static java.applet.AudioClip crashSound
static java.applet.AudioClip explosionSound
static java.applet.AudioClip fireSound
static java.applet.AudioClip missileSound
static java.applet.AudioClip saucerSound
static java.applet.AudioClip thrustersSound
static java.applet.AudioClip warpSound
static final int START_PIXELWIDTH
static final int START_PIXELHEIGHT
static RealPixelConverter realpixelconverter
private double timestep
static boolean soundflag
boolean detail
AsteroidsGame asteroidsgame
java.awt.Font font
java.awt.FontMetrics fontmetric
int fontWidth
int fontHeight
java.lang.String currentsoundfilename
java.awt.Dimension offDimension
java.awt.Image offImage
java.awt.Graphics offGraphics
boolean trueapplet
Constructor Detail |
public Asteroids()
Method Detail |
double scale()
double widthpixel()
double heightpixel()
public void setPixelWindow(java.awt.Dimension d)
public java.lang.String getAppletInfo()
public boolean isFocusTraversable()
public void init()
public void start()
public void stop()
public void loadSounds()
public java.applet.AudioClip loadSound(java.lang.String soundname)
public void run()
public boolean keyDown(java.awt.Event e, int key)
public boolean keyUp(java.awt.Event e, int key)
public void paint(java.awt.Graphics g)
public void update(java.awt.Graphics g)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |