public class MyXlet
extends java.awt.Container
implements javax.tv.xlet.Xlet, java.lang.Runnable, org.dvb.event.UserEventListener
Modifier and Type | Field and Description |
---|---|
private java.awt.Image |
backbuffer
image for double buffering
|
private ImageEntity |
background
game background
|
private Sprite |
bird
player sprite
|
(package private) int |
BIRDDEATHBOUNDRY
constant for y point to determine if bird has died
|
(package private) int |
BIRDTOPBOUNDRY
constant for y point to clip bird to top of screen
|
private Sprite[] |
bottomPipe
bottom pipe sprite
|
private java.awt.Font |
font
scene font for text display
|
private java.lang.Thread |
gameloop
thread for the game loop
|
(package private) int |
GRAVITY
gravity
|
private int |
MAXPIPESPRITES
max number of pipe sprites
|
(package private) int |
PIPESTARTINGXVELOCITY
constant for pipe starting speed
|
private org.havi.ui.HScene |
scene
scene to draw on
|
(package private) int |
score
players score
|
(package private) int |
SCREENCENTERX
constant for the x coordinate of the center of the screen
|
(package private) int |
SCREENCENTERY
constant for the y coordinate of the center of the screen
|
(package private) int |
SCREENHEIGHT
constant for the screen height
|
(package private) int |
SCREENWIDTH
constant for the screen width
|
(package private) int |
state
game state
|
private Sprite[] |
topPipe
top pipe sprite
|
(package private) int |
UPFORCEY
constant for bird's max up speed
|
private SoundClip |
wingFlap
sample for wing flap
|
Constructor and Description |
---|
MyXlet() |
Modifier and Type | Method and Description |
---|---|
void |
birdUpdate()
update the birds position
|
void |
destroyXlet(boolean unconditional)
returns the memory used by the xlet and terminates the thread used for the game loop
|
void |
drawPipes(java.awt.Graphics backbuffer)
draws the pipes
|
void |
gameUpdate()
updates all the game objects
|
void |
initXlet(javax.tv.xlet.XletContext context)
initializes the xlet, starts the background music, creates the double buffer, initializes all the
game objects and sets up the input handlers
|
void |
paint(java.awt.Graphics g)
draws all the game entities to the back buffer and then the back buffer to the screen
|
void |
pauseXlet()
hides the scene
|
void |
pipeUpdate()
update the pipes' positions
|
void |
run()
main game loop
|
void |
startXlet()
makes the scene visible, starts the game loop and calls repaint to draw the first frame
|
void |
userEventReceived(org.dvb.event.UserEvent evt)
listens for key events and handles them
|
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, isValidateRoot, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
final int SCREENWIDTH
final int SCREENHEIGHT
final int SCREENCENTERX
final int SCREENCENTERY
final int UPFORCEY
final int PIPESTARTINGXVELOCITY
final int GRAVITY
final int BIRDTOPBOUNDRY
final int BIRDDEATHBOUNDRY
private final int MAXPIPESPRITES
private org.havi.ui.HScene scene
private java.awt.Font font
private java.lang.Thread gameloop
private java.awt.Image backbuffer
int state
int score
private ImageEntity background
private Sprite bird
private Sprite[] topPipe
private Sprite[] bottomPipe
private SoundClip wingFlap
public void initXlet(javax.tv.xlet.XletContext context)
initXlet
in interface javax.tv.xlet.Xlet
context
- xlet contextpublic void startXlet()
startXlet
in interface javax.tv.xlet.Xlet
public void pauseXlet()
pauseXlet
in interface javax.tv.xlet.Xlet
public void destroyXlet(boolean unconditional)
destroyXlet
in interface javax.tv.xlet.Xlet
unconditional
- terminate conditionally if true, otherwise falsepublic void run()
run
in interface java.lang.Runnable
public void gameUpdate()
public void pipeUpdate()
public void birdUpdate()
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
g
- graphics context to use for drawingpublic void drawPipes(java.awt.Graphics backbuffer)
backbuffer
- backbuffer imagepublic void userEventReceived(org.dvb.event.UserEvent evt)
userEventReceived
in interface org.dvb.event.UserEventListener
evt
- key event