Class TorusMan

  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by jgame.platform.JGEngine
                      extended by dk.itu.smds.util.JGEngine
                          extended by dk.itu.smds.torusman.TorusMan
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer,, javax.accessibility.Accessible, jgame.impl.JGEngineInterface

public class TorusMan
extends dk.itu.smds.util.JGEngine

Tutorial example 1: a minimal program. A "bare skeleton" program displaying a moving text "hello world". In order to run as both applet and application, you need to define a main() method (this is the entry point for an application) and a parameterless constructor (this is the entry point for an applet). We use a second constructor with a size parameter to initialise the engine as an application.

See Also:
Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from class java.awt.Component
Field Summary
Fields inherited from class jgame.platform.JGEngine
KeyBackspace, KeyTab
Fields inherited from class java.awt.Component
Fields inherited from interface jgame.impl.JGEngineInterface
CROSSHAIR_CURSOR, DEFAULT_CURSOR, HAND_CURSOR, KeyAlt, KeyCtrl, KeyDown, KeyEnter, KeyEsc, KeyFire, KeyLeft, KeyMouse1, KeyMouse2, KeyMouse3, KeyPound, KeyRight, KeyShift, KeyStar, KeyUp, WAIT_CURSOR
Fields inherited from interface java.awt.image.ImageObserver
Constructor Summary
          The parameterless constructor is called by the browser, in case we're an applet.
TorusMan(jgame.JGPoint size)
          We use a separate constructor for starting as an application.
Method Summary
 void doFrame()
          Game logic is done here.
 void initCanvas()
          This method is called by the engine when it is ready to intialise the canvas (for an applet, this is after the browser has called init()).
 void initGame()
          This method is called when the engine has finished initialising and is ready to produce frames.
static void main(java.lang.String[] args)
          The main method.
 void paintFrame()
          Any graphics drawing beside objects or tiles should be done here.
 void startApp()
Methods inherited from class jgame.platform.JGEngine
addGameState, and, andTileCid, atan2, checkBGCollision, checkBGCollision, checkCollision, checkCollision, clearGameState, clearKey, clearLastKey, clearMouseButton, countObjects, countObjects, countTiles, dbgExceptionToString, dbgPrint, dbgPrint, dbgSetDebugColor1, dbgSetDebugColor2, dbgSetMessageExpiry, dbgSetMessageFont, dbgShowBoundingBox, dbgShowException, dbgShowFullStackTrace, dbgShowGameState, dbgShowMessagesInPf, defineAnimation, defineAnimation, defineAudioClip, defineImage, defineImage, defineImage, defineImage, defineImageMap, defineMedia, destroy, disableAudio, displayHeight, displayWidth, drawImage, drawImage, drawImageString, drawImageString, drawLine, drawLine, drawLine, drawOval, drawOval, drawOval, drawRect, drawRect, drawRect, drawString, drawString, drawString, drawTile, enableAudio, existsObject, exitEngine, fillBG, getAnimation, getAWTColor, getBufferGraphics, getConfigPath, getFontHeight, getFrameRate, getFrameSkip, getGameSpeed, getImage, getImageBBox, getImageSize, getKey, getKeyCode, getKeyCodeStatic, getKeyDesc, getKeyDescStatic, getLastKey, getLastKeyChar, getMinScaleFactor, getMouseButton, getMouseInside, getMousePos, getMouseX, getMouseY, getObject, getObjects, getOffscreenMarginX, getOffscreenMarginY, getTileCid, getTileCid, getTileCid, getTileCidAtCoord, getTileCoord, getTileCoord, getTileIndex, getTiles, getTiles, getTileStr, getTileStr, getTileStrAtCoord, getXAlignOfs, getXDist, getXScaleFactor, getYAlignOfs, getYDist, getYScaleFactor, inGameState, inGameStateNextFrame, init, initEngine, initEngineApplet, isApplet, isMidlet, isXAligned, isYAligned, lastPlayedAudio, markAddObject, moduloXPos, moduloYPos, moveObjects, moveObjects, orTileCid, pfHeight, pfTilesX, pfTilesY, pfWidth, pfWrapX, pfWrapY, playAudio, playAudio, random, random, random, registerTimer, removeAllTimers, removeGameState, removeObject, removeObjects, removeObjects, requestGameFocus, setAuthorMessage, setBGColor, setBGImage, setCanvasSettings, setColor, setColorsFont, setFGColor, setFont, setFont, setFrameRate, setGameSpeed, setGameState, setKey, setMouseButton, setMouseCursor, setMouseCursor, setMsgFont, setOffscreenMargin, setPFSize, setPFWrap, setProgressBar, setProgressMessage, setRenderSettings, setScalingPreferences, setStroke, setTextOutline, setTile, setTile, setTileCid, setTileCid, setTiles, setTileSettings, setTilesMulti, setViewOffset, snapToGrid, snapToGridX, snapToGridY, start, stop, stopAudio, stopAudio, tileHeight, tileWidth, viewHeight, viewTilesX, viewTilesY, viewWidth, viewXOfs, viewYOfs, wakeUpOnKey
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, 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, 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, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, 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, transferFocusUpCycle
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public TorusMan()
The parameterless constructor is called by the browser, in case we're an applet.


public TorusMan(jgame.JGPoint size)
We use a separate constructor for starting as an application.

size - the size
Method Detail


public static void main(java.lang.String[] args)
The main method.

args - the arguments


public void startApp()

startApp in class dk.itu.smds.util.JGEngine
See Also:


public void initCanvas()
This method is called by the engine when it is ready to intialise the canvas (for an applet, this is after the browser has called init()). Note that applet parameters become available here and not earlier (don't try to access them from within the parameterless constructor!). Use isApplet() to check if we started as an applet.

Specified by:
initCanvas in interface jgame.impl.JGEngineInterface
Specified by:
initCanvas in class jgame.platform.JGEngine


public void initGame()
This method is called when the engine has finished initialising and is ready to produce frames. Note that the engine logic runs in its own thread, separate from the AWT event thread, which is used for painting only. This method is the first to be called from within its thread. During this method, the game window shows the intro screen.

Specified by:
initGame in interface jgame.impl.JGEngineInterface
Specified by:
initGame in class jgame.platform.JGEngine


public void doFrame()
Game logic is done here. No painting can be done here, define paintFrame to do that.

Specified by:
doFrame in interface jgame.impl.JGEngineInterface
doFrame in class jgame.platform.JGEngine


public void paintFrame()
Any graphics drawing beside objects or tiles should be done here. Usually, only status / HUD information needs to be drawn here.

Specified by:
paintFrame in interface jgame.impl.JGEngineInterface
paintFrame in class jgame.platform.JGEngine