|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
game.CGameCanvas
public class CGameCanvas
The game Canvas, implementing the IGame and IGameDisplay interfaces. Responds to user actions through controllers as well.
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
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 | |
---|---|
private |
CGameCanvas()
Basic constructor (if no resource - gfx or sound - needs to be loaded). |
|
CGameCanvas(IGameApplication gameApplication)
Resource loading constructor. |
Method Summary | |
---|---|
private void |
addHitText(int nbHits,
int increment,
int multiplier,
float x,
float y)
|
private void |
addRandomBall()
|
private void |
addRandomRect()
|
private void |
addStaticData()
(Re)inits internal data. |
void |
animate(float dt)
Animation function called by the game loop. |
private void |
checkState()
Checks controller inputs. |
void |
clear()
Clears internal data. |
void |
draw()
The drawing function called by the game loop. |
private void |
draw(java.awt.Graphics g)
Internal drawing function. |
private java.awt.Image |
generateBGImage()
Computes the background image. |
private java.awt.Image |
generateIntroImage()
Computes the intro (credits) image. |
private void |
generateSparkles(CVector2D position,
CVector2D velocity)
Generates sparkles. |
CBitmapFont |
getBlueFont()
|
CBitmapFont |
getBoldFont()
|
CBitmapFont |
getDefaultFont()
|
CBitmapFont |
getGreenFont()
|
CBitmapFont |
getRedFont()
|
int |
getX()
IGameDisplay implementation. |
int |
getY()
IGameDisplay implementation. |
private void |
init()
(Re)inits internal data. |
void |
mouseClicked(java.awt.event.MouseEvent arg0)
|
void |
mouseEntered(java.awt.event.MouseEvent arg0)
|
void |
mouseExited(java.awt.event.MouseEvent arg0)
|
void |
mousePressed(java.awt.event.MouseEvent arg0)
|
void |
mouseReleased(java.awt.event.MouseEvent arg0)
|
void |
paint(java.awt.Graphics g)
Canvas override. |
private void |
pause()
Pauses the animation. |
private void |
plugController(CGameController gc)
Game controller declaration. |
private void |
plugMouseController(CMouseController mc)
Mouse controller declaration. |
private void |
popNHitGraphicObject(IGraphicObject go)
Pops an object and registers a hit. |
private void |
recordControllerStates()
Records current controllers state. |
private void |
restart()
Restarts the game. |
void |
setBounds(int arg0,
int arg1,
int arg2,
int arg3)
Component override. |
void |
startLoop()
Called by the Applet or main application to start the game loop. |
void |
stopLoop()
Called by the Applet or main application to stop the game loop. |
private void |
unpause()
Unpauses the animation. |
void |
update(java.awt.Graphics g)
Canvas override. |
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, 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, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, 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, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, 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 |
Methods inherited from interface game.IGameDisplay |
---|
getHeight, getWidth |
Field Detail |
---|
public static final java.lang.String STR_NAME
public static final java.lang.String STR_VERSION
public static final java.lang.String STR_DATE
public static final float FPS
private long m_msStartTime
private CGameLoop m_gameLoop
private boolean m_showDebugText
public static final int W
public static final int H
public static final java.awt.Color DEFAULT_COLOR
public static final java.awt.Color SHADOW_COLOR
public static final java.awt.Color TITLE_BG_COLOR
public static final java.awt.Color GAME_BG_COLOR
private volatile boolean m_cantDraw
private volatile boolean m_isDrawing
private volatile boolean m_cantAnimate
private CGraphicLayer m_cBackgroundLayer
private CCriticalLayer m_cCriticalLayer
private CEphemereLayer m_cEphemereLayer
private CGraphicLayer m_cTextLayer
private java.awt.Image m_offscreenImage
private java.awt.Graphics m_backBuffer
private CStaticSprite m_scoreBoxSprite
private CAnimatedSprite m_ball
private java.awt.Image m_introImage
private java.awt.Image m_bgImage
private CEphemereMessage m_criticalWarning
private COnscreenMessage m_pressStart
private CBitmapFont m_bmpFont_13
private CBitmapFont m_bmpBoldFont_9
private CBitmapFont m_bmpRedFont
private CBitmapFont m_bmpGreenFont
private CBitmapFont m_bmpBlueFont
private CGameController m_gameController1
private CMouseController m_mouseController
private CScoreManager m_scoreManager
private CHighscoreTable m_highscoreTable
private IGameApplication m_gameApplication
Constructor Detail |
---|
private CGameCanvas()
public CGameCanvas(IGameApplication gameApplication)
gameApplication
- : the object that can access and load resources.Method Detail |
---|
private void addStaticData()
private void plugController(CGameController gc)
private void plugMouseController(CMouseController mc)
private void init()
public void clear()
private void restart()
public void startLoop()
public void stopLoop()
private void pause()
private void unpause()
private void checkState()
private void recordControllerStates()
private void addHitText(int nbHits, int increment, int multiplier, float x, float y)
private final void popNHitGraphicObject(IGraphicObject go)
go
- : the IGraphicObject to pop.private final void generateSparkles(CVector2D position, CVector2D velocity)
position
- : origin of the sparklesvelocity
- : average speed of the sparklespublic void animate(float dt)
animate
in interface IGame
dt
- : the amount of game time since last frame. Can be fixed (frame based anim.) or variable (real time based anim.).public final void draw()
draw
in interface IGame
private final void draw(java.awt.Graphics g)
g
- : the Graphics to draw to.private void addRandomRect()
private void addRandomBall()
public final void paint(java.awt.Graphics g)
super.paint()
.
paint
in class java.awt.Canvas
g
- public final void update(java.awt.Graphics g)
update
in class java.awt.Canvas
g
- public void setBounds(int arg0, int arg1, int arg2, int arg3)
setBounds
in class java.awt.Component
public final int getX()
getX
in interface IGameDisplay
getX
in class java.awt.Component
public final int getY()
getY
in interface IGameDisplay
getY
in class java.awt.Component
public final CBitmapFont getDefaultFont()
getDefaultFont
in interface IGameDisplay
public final CBitmapFont getBoldFont()
getBoldFont
in interface IGameDisplay
public final CBitmapFont getRedFont()
getRedFont
in interface IGameDisplay
public final CBitmapFont getGreenFont()
getGreenFont
in interface IGameDisplay
public final CBitmapFont getBlueFont()
getBlueFont
in interface IGameDisplay
public void mouseClicked(java.awt.event.MouseEvent arg0)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent arg0)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent arg0)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent arg0)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent arg0)
mouseReleased
in interface java.awt.event.MouseListener
private java.awt.Image generateBGImage()
private java.awt.Image generateIntroImage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |