Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jgame
Class StdGame

    java.lang.Object
      java.awt.Component
          java.awt.Container
              java.awt.Panel
                  java.applet.Applet
                      jgame.JGEngine
                          jgame.StdGame

All Implemented Interfaces:
  java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

    public abstract class StdGame

extends JGEngine

A basic framework for a game. It supports an animation and game timer, object creation at fixed intervals, score, lives, levels, configurable keys. There are title, start-level, next-level, death, and game-over sequences. Todo: highscores, key configuration file and GUI.

To initialise this class, use the regular initEngine (from main), or initEngineApplet (from parameterless constructor). You can supply the width and height of the window as command line arguments by calling parseSizeArgs(args) from your main(). Define initGame() as usual. StdGame does all its logic in the doFrame method, so you should ensure that it is called (i.e. call super.doFrame() if you choose to override doFrame). The game will automatically start in the "Title" gamestate when it finds that it isn't in this state in the first call to doFrame(). You can also set the "Title" state in initGame if you even want the first frame to be in "Title".

The class uses the following state machine, using JGEngine's state machine mechanism:

Title: displays title screen. Transition to {StartLevel,StartGame} when the key_startgame is pressed. Before the transition, initNewGame(), defineLevel(), and initNewLife() are called.

InGame: game is playing. Transition to LifeLost when lifeLost() is called from within the game. Transition to LevelDone when levelDone() is called from within the game. Transition to GameOver when gameOver() is called (i.e. to quit game). The gametime timer indicates how many ticks the game has been running since the beginning of the level.

StdGame supports a set of standard game sequences, which are represented as game states: StartLevel/StartGame, LevelDone, LifeLost, GameOver. These can be configured so they add the InGame state to the sequence state (i.e. the game is in both states simultaneously). This can be used to animate the game while playing the corresponding sequence. This is off by default. The seqtimer timer is set to 0 at the beginning of each sequence, and increments during the sequence to indicate how many ticks the sequence has been playing. The number of ticks that the sequence should take can be configured, or the sequence can be skipped altogether by setting ticks to 0.

StartGame: start game sequence is played. Transition to InGame after a certain time has elapsed or the continuegame key is pressed.

StartLevel: start level sequence is played. Transition to InGame after a certain time has elapsed or the continuegame key is pressed. Is always active in combination with StartGame; it's just an indication that StartGame is also a start of a new level.

LevelDone: next level sequence is played. Transition to StartLevel/StartGame after a certain time has elapsed or the continuegame key is pressed. Before the transition, resp. incrementLevel() and defineLevel() are called.

LifeLost: player has just died, a death sequence is played. Transition to either GameOver or StartGame after a certain time has elapsed or the continuegame key is pressed, dependent of whether there are lives left. Before the transition to StartGame, decrementLives() and initNewLife are called.

GameOver: game over sequence is played. Transition to Title after a certain time or the continuegame key is pressed.

Built in are also game exit (through the key_quitgame, which is Escape by default), and pause game (through the key_pausegame, which defaults to 'P').

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class java.applet.Applet
`java.applet.Applet.AccessibleApplet`

Nested classes/interfaces inherited from class java.awt.Panel
`java.awt.Panel.AccessibleAWTPanel`

Nested classes/interfaces inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Nested classes/interfaces inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

Field Summary
`AppConfig` | `appconfig` The application configuration handler.
`boolean` | `audioenabled` Flag indicating that audio is enabled
`boolean` | `gameover_ingame` Indicates whether the InGame state should be retained when in the corresponding sequence state.
`int` | `gameover_ticks` Number of ticks to stay in GameOver state, 0 = skip
`int` | `gametime` Game timer.
`int` | `initial_lives` Initial value for lives; default=4
`int` | `key_action` Key for special action, default=X
`int` | `key_continuegame` Key for continuing the game when in a sequence, default = space.
`int` | `key_down` Key for moving, default = cursors.
`int` | `key_fire` Key for firing (in case there are no separate directional fire keys), default=Z.
`int` | `key_firedown` Key for directional firing, default = WSAD keys
`int` | `key_fireleft` Key for directional firing, default = WSAD keys
`int` | `key_fireright` Key for directional firing, default = WSAD keys
`int` | `key_fireup` Key for directional firing, default = WSAD keys
`int` | `key_gamesettings` Key for invoking the game settings window, default = enter.
`int` | `key_left` Key for moving, default = cursors.
`int` | `key_pausegame` Key for pausing the game, default = P.
`int` | `key_quitgame` Key for quitting the game, default = escape.
`int` | `key_right` Key for moving, default = cursors.
`int` | `key_startgame` Key for starting the game, default = space.
`int` | `key_up` Key for moving, default = cursors.
`int` | `level` Difficulty level; starts at 0 at beginning of game.
`boolean` | `leveldone_ingame` Indicates whether the InGame state should be retained when in the corresponding sequence state.
`int` | `leveldone_ticks` Number of ticks to stay in LevelDone state, 0 = skip
`boolean` | `lifelost_ingame` Indicates whether the InGame state should be retained when in the corresponding sequence state.
`int` | `lifelost_ticks` Number of ticks to stay in LifeLost state, 0 = skip
`int` | `lives` Lives count, 0 means game over.
`java.lang.String` | `lives_img` Image to use to display lives
`int` | `score` Player score; starts at 0 at beginning of game.
`int` | `seqtimer` Sequence timer.
`int` | `stage` Game stage, which is usually the same as level, but typically goes on counting, while level may stop increasing at a certain value.
`boolean` | `startgame_ingame` Indicates whether the InGame state should be retained when in the corresponding sequence state.
`int` | `startgame_ticks` Number of ticks to stay in StartLevel/StartGame state, 0 = skip
`java.awt.Color` | `status_color` Color to use to display score
`java.awt.Font` | `status_font` Font to use to display score
`int` | `timer` Animation timer.
`java.awt.Color` | `title_bg_color` Color to use to display background effects behind title and messages
`java.awt.Color` | `title_color` Color to use to display title and messages
`java.awt.Font` | `title_font` Font to use to display title and messages

Fields inherited from class jgame.JGEngine
`KeyAlt, KeyCtrl, KeyDown, KeyEnter, KeyEsc, KeyLeft, KeyMouse1, KeyMouse2, KeyMouse3, KeyRight, KeyShift, KeyUp`

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
`StdGame()`

Method Summary
`boolean` | `checkTime(int increment)` Returns true every increment ticks.
`boolean` | `checkTime(int min_time, int max_time, int increment)` Returns true every increment ticks, but only when gametime is between min_time and max_time.
`java.awt.Color` | `cycleColor(java.awt.Color[] cycle, int tmr, double speed)` Get a colour from a colour cycle.
`void` | `decrementLives()` Code for losing a life before transition from LifeLost to InGame is made.
`void` | `defineLevel()` Initialise a level.
`void` | `doFrame()` The main doFrame takes care of all the standard game actions.
`void` | `drawCount(int count, java.lang.String image, int x, int y, int increment_x)` Draw a row of objects to indicate the value count.
`void` | `drawWavyString(java.lang.String s, int x, int y, int align, int increment_x, int tmr, double amplitude, double pos_phaseshift, double timer_phaseshift, java.awt.Font font, java.awt.Color col)` Draw a string with letters that move up and down individually.
`void` | `gameOver()` Call to make straight transition to GameOver; is called automatically by lifeLost when appropriate.
`java.lang.String` | `getConfigPath(java.lang.String filename)` Returns path to writable location for a file with the given name.
`java.awt.Font` | `getZoomingFont(java.awt.Font basefont, int tmr, double min_size_fac, double speed)` Get font for zooming text in and out.
`void` | `incrementLevel()` Code for incrementing a level before transition from LevelDone to InGame is made.
`void` | `initAppConfig()` Define appconfig for configuring keys.
`void` | `initNewGame()` Initialise the game when a new game is started.
`void` | `initNewLife()` Initialise play specifically after a new life is introduced (that is, at game start and after the player has died.
`void` | `levelDone()` Call to make state transition to LevelDone.
`void` | `lifeLost()` Call to make state transition to LifeLost.
`void` | `paintFrame()` Default paintFrame displays score at top left, lives at top right.
`void` | `paintFrameGameOver()` Default displays "Game Over!".
`void` | `paintFrameLevelDone()` Default displays "Level Done !".
`void` | `paintFrameLifeLost()` Default displays "Life Lost !".
`void` | `paintFramePaused()` The game is halted in pause mode, but the paintFrame is still done to refresh the screen.
`void` | `paintFrameStartGame()` Default displays "Start !".
`void` | `paintFrameStartLevel()` Default displays "Level "+(stage+1).
`void` | `paintFrameTitle()` Default displays class name as title, and "press [key_startgame] to start" below it.
`static java.awt.Dimension` | `parseSizeArgs(java.lang.String[] args, int arg_ofs)` Look for two arguments starting at index arg_ofs, and parse them as width and height.
`int` | `posWalkForwards(int begin_pos, int end_pos, int tmr, int end_time, int standstill_pos, int standstill_time, int standstill_count)` Walk across the screen, standing still momentarily at a specific position.
`void` | `setSequences(boolean startgame_ingame, int startgame_ticks, boolean leveldone_ingame, int leveldone_ticks, boolean lifelost_ingame, int lifelost_ticks, boolean gameover_ingame, int gameover_ticks)` Set all sequence variables in one go.
`void` | `setStatusDisplay(java.awt.Font status_font, java.awt.Color status_color, java.lang.String lives_img)` Set the status display variables in one go.
`void` | `startGameOver()` Initialise game over sequence.
`void` | `startInGame()` Initialisation at the start of the in-game action.
`void` | `startLevelDone()` Initialise next-level sequence.
`void` | `startLifeLost()` Initialise death sequence.
`void` | `startStartGame()` Initialise start-game sequence.
`void` | `startStartLevel()` Initialise start-level sequence.
`void` | `startTitle()` Initialise the title screen.

Methods inherited from class jgame.JGEngine
`addGameState, and, andTileCid, checkBGCollision, checkBGCollision, checkCollision, clearGameState, clearKey, clearMouseButton, countObjects, countObjects, countTiles, dbgExceptionToString, dbgPrint, dbgPrint, dbgSetDebugColor1, dbgSetDebugColor2, dbgSetMessageExpiry, dbgSetMessageFont, dbgShowBoundingBox, dbgShowException, dbgShowFullStackTrace, dbgShowGameState, dbgShowMessagesInPf, defineAnimation, defineAnimation, defineAudioClip, defineGraphics, defineImage, defineImage, defineImage, defineImage, defineImageMap, defineMedia, destroy, disableAudio, drawImage, drawImage, drawImageString, drawImageString, drawLine, drawLine, drawLine, drawOval, drawOval, drawOval, drawRect, drawRect, drawRect, drawString, drawString, drawString, enableAudio, existsObject, exitEngine, fillBG, getBufferGraphics, getFontHeight, getFrameRate, getFrameSkip, getImage, getImageBBox, getImageSize, getKey, getKeyCode, getKeyDesc, getMinScaleFactor, getMouseButton, getMouseInside, getMousePos, getMouseX, getMouseY, getObject, getTileCid, getTileCid, getTileCid, getTileCidAtCoord, getTileCoord, getTileCoord, getTileIndex, getTiles, getTileStr, getTileStr, getTileStrAtCoord, getXAlignOfs, getXScaleFactor, getYAlignOfs, getYScaleFactor, inGameState, inGameStateNextFrame, init, initCanvas, initEngine, initEngineApplet, initGame, isApplet, isXAligned, isYAligned, lastPlayedAudio, moveObjects, moveObjects, orTileCid, pfHeight, pfTileHeight, pfTilesX, pfTilesY, pfTileWidth, pfWidth, playAudio, playAudio, random, random, random, removeAllTimers, removeGameState, removeObjects, removeObjects, requestGameFocus, setBGColor, setBGImage, setCanvasSettings, setColor, setColorsFont, setCursor, setFGColor, setFont, setFont, setFrameRate, setGameState, setKey, setMouseButton, setMsgFont, setOffscreenMargin, setPFSize, setRenderSettings, setStroke, setTextOutline, setTile, setTile, 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
`addNotify`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, 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, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree`

Methods inherited from class java.awt.Component
`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, getBackground, 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, 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, setBackground, setBounds, setBounds, setComponentOrientation, 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
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### audioenabled

    public boolean audioenabled

  Flag indicating that audio is enabled

### key_startgame

    public int key_startgame

  Key for starting the game, default = space.

### key_gamesettings

    public int key_gamesettings

  Key for invoking the game settings window, default = enter.

### key_continuegame

    public int key_continuegame

  Key for continuing the game when in a sequence, default = space.

### key_quitgame

    public int key_quitgame

  Key for quitting the game, default = escape.

### key_pausegame

    public int key_pausegame

  Key for pausing the game, default = P.

### key_left

    public int key_left

  Key for moving, default = cursors.

### key_right

    public int key_right

  Key for moving, default = cursors.

### key_up

    public int key_up

  Key for moving, default = cursors.

### key_down

    public int key_down

  Key for moving, default = cursors.

### key_fire

    public int key_fire

  Key for firing (in case there are no separate directional fire keys), default=Z.

### key_fireleft

    public int key_fireleft

  Key for directional firing, default = WSAD keys

### key_fireright

    public int key_fireright

  Key for directional firing, default = WSAD keys

### key_fireup

    public int key_fireup

  Key for directional firing, default = WSAD keys

### key_firedown

    public int key_firedown

  Key for directional firing, default = WSAD keys

### key_action

    public int key_action

  Key for special action, default=X

### gametime

    public int gametime

  Game timer. Is reset to 0 at the beginning of each level, increments during InGame.

### seqtimer

    public int seqtimer

  Sequence timer. Is reset to 0 at the start of the Title, StartLevel, StartGame, LevelDone, LifeLost, GameOver sequences. Counts always. Can be used to time animations for these sequences.

### timer

    public int timer

  Animation timer. Always continues on counting. Can be used to time animations etc.

### score

    public int score

  Player score; starts at 0 at beginning of game.

### level

    public int level

  Difficulty level; starts at 0 at beginning of game. Can be incremented each time a level is complete. Can be used to determine game difficulty settings throughout the game.

### stage

    public int stage

  Game stage, which is usually the same as level, but typically goes on counting, while level may stop increasing at a certain value. Can be used to vary graphic sets, display stage number, etc.

### lives

    public int lives

  Lives count, 0 means game over.

### initial_lives

    public int initial_lives

  Initial value for lives; default=4

### startgame_ticks

    public int startgame_ticks

  Number of ticks to stay in StartLevel/StartGame state, 0 = skip

### leveldone_ticks

    public int leveldone_ticks

  Number of ticks to stay in LevelDone state, 0 = skip

### lifelost_ticks

    public int lifelost_ticks

  Number of ticks to stay in LifeLost state, 0 = skip

### gameover_ticks

    public int gameover_ticks

  Number of ticks to stay in GameOver state, 0 = skip

### startgame_ingame

    public boolean startgame_ingame

  Indicates whether the InGame state should be retained when in the corresponding sequence state.

### leveldone_ingame

    public boolean leveldone_ingame

  Indicates whether the InGame state should be retained when in the corresponding sequence state.

### lifelost_ingame

    public boolean lifelost_ingame

  Indicates whether the InGame state should be retained when in the corresponding sequence state.

### gameover_ingame

    public boolean gameover_ingame

  Indicates whether the InGame state should be retained when in the corresponding sequence state.

### status_font

    public java.awt.Font status_font

  Font to use to display score

### status_color

    public java.awt.Color status_color

  Color to use to display score

### lives_img

    public java.lang.String lives_img

  Image to use to display lives

### title_font

    public java.awt.Font title_font

  Font to use to display title and messages

### title_color

    public java.awt.Color title_color

  Color to use to display title and messages

### title_bg_color

    public java.awt.Color title_bg_color

  Color to use to display background effects behind title and messages

### appconfig

    public AppConfig appconfig

  The application configuration handler. Default is null, use initAppConfig to initialise it.

Constructor Detail

### StdGame

    public StdGame()

Method Detail

### setStatusDisplay

    public void setStatusDisplay(java.awt.Font status_font,
                                 java.awt.Color status_color,
                                 java.lang.String lives_img)

  Set the status display variables in one go.

### setSequences

    public void setSequences(boolean startgame_ingame,
                             int startgame_ticks,
                             boolean leveldone_ingame,
                             int leveldone_ticks,
                             boolean lifelost_ingame,
                             int lifelost_ticks,
                             boolean gameover_ingame,
                             int gameover_ticks)

  Set all sequence variables in one go.

### parseSizeArgs

    public static java.awt.Dimension parseSizeArgs(java.lang.String[] args,
                                                   int arg_ofs)

  Look for two arguments starting at index arg_ofs, and parse them as width and height. Returns (0.0) if there are no arguments. Prints a usage message otherwise.

### getConfigPath

    public java.lang.String getConfigPath(java.lang.String filename)

  Returns path to writable location for a file with the given name. Basically it uses [user.home] / .jgame / [filename], with "/" being the system path separator. In case [user.home] / .jgame does not exist, it is created. In case .jgame is not a directory, null is returned. In case the file does not exist yet, an empty file is created.

  Returns:
    path to writable file, or null if not possible

### initNewGame

    public void initNewGame()

  Initialise the game when a new game is started. Default sets level, stage, score to 0, and lives to initial_lives.

### initNewLife

    public void initNewLife()

  Initialise play specifically after a new life is introduced (that is, at game start and after the player has died. This is typically used to reinitialise the player. If you want a specific initialisation at both the beginning of the level or after the player death, use startInGame(). Default is do nothing.

### defineLevel

    public void defineLevel()

  Initialise a level. Default is do nothing.

### decrementLives

    public void decrementLives()

  Code for losing a life before transition from LifeLost to InGame is made. Default is decrement lives.

### incrementLevel

    public void incrementLevel()

  Code for incrementing a level before transition from LevelDone to InGame is made. Default is increment level and stage.

### lifeLost

    public final void lifeLost()

  Call to make state transition to LifeLost. Is ignored when in another state than InGame or {InGame,StartLevel/StartGame}. After the LifeLost sequence, goes to InGame or GameOver, depending on lives left.

### levelDone

    public final void levelDone()

  Call to make state transition to LevelDone. Is ignored when state is not InGame or {Ingame,StartLevel/StartGame}. After the LevelDone sequence, it sets gametime to 0, calls incrementLevel and defineLevel, and goes to StartLevel/StartGame.

### gameOver

    public final void gameOver()

  Call to make straight transition to GameOver; is called automatically by lifeLost when appropriate. Is ignored when game state is not {InGame}, {Ingame,Start*}, or LifeLost. Will go to Title after GameOver sequence.

### initAppConfig

    public void initAppConfig()

  Define appconfig for configuring keys. Override to define your own appconfig; define an empty method to remove the ability of game configuration. Default behaviour is: create appconfig, set the "key_" fields as configuration fields, then load them from a file named $JGAMEHOME/[classname].cfg, and save these in the StdGame object. Create your own AppConfig like this:

       appconfig = new AppConfig("[title]", this, getConfigPath("[filename]");

  getConfigPath returns a path to a writable file in [user.home]/.jgame/

### doFrame

    public void doFrame()

  The main doFrame takes care of all the standard game actions. If you override it, you should typically call super.doFrame(). doFrame increments timer, increments gametime when in InGame, quits game when key_quitgame is pressed in InGame. In Title, it waits for the user to press the key_startgame, then sets gametime to 0, calls initNewGame, defineLevel, and goes to StartLevel. It also handles the continue_game key inside the sequences, and the gamesettings key in Title. It also ensures the audioenabled flag is passed to engine.

  Overrides:
    `doFrame` in class `JGEngine`

### startTitle

    public void startTitle()

  Initialise the title screen. This is a standard state transition function. Default is do nothing.

### startInGame

    public void startInGame()

  Initialisation at the start of the in-game action. This is a standard state transition function. Note that it is always called after StartLevel and LifeLost, even if startgame_ingame and lifelost_ingame are set. Default is do nothing.

### startStartLevel

    public void startStartLevel()

  Initialise start-level sequence. This is a standard state transition function. Default is do nothing.

### startStartGame

    public void startStartGame()

  Initialise start-game sequence. This is a standard state transition function. Default is do nothing.

### startLevelDone

    public void startLevelDone()

  Initialise next-level sequence. This is a standard state transition function. Default is do nothing.

### startLifeLost

    public void startLifeLost()

  Initialise death sequence. This is a standard state transition function. Default is do nothing.

### startGameOver

    public void startGameOver()

  Initialise game over sequence. This is a standard state transition function. Default is do nothing.

### paintFrame

    public void paintFrame()

  Default paintFrame displays score at top left, lives at top right. When lives_img is set, it uses that image to display lives.

  Overrides:
    `paintFrame` in class `JGEngine`

### paintFrameTitle

    public void paintFrameTitle()

  Default displays class name as title, and "press [key_startgame] to start" below it.

### paintFramePaused

    public void paintFramePaused()

  The game is halted in pause mode, but the paintFrame is still done to refresh the screen. Default behaviour of paintFramePaused() is display "Paused", "Press [key_pausegame] to continue" using title_font, title_color

### paintFrameStartLevel

    public void paintFrameStartLevel()

  Default displays "Level "+(stage+1).

### paintFrameStartGame

    public void paintFrameStartGame()

  Default displays "Start !".

### paintFrameLevelDone

    public void paintFrameLevelDone()

  Default displays "Level Done !".

### paintFrameLifeLost

    public void paintFrameLifeLost()

  Default displays "Life Lost !".

### paintFrameGameOver

    public void paintFrameGameOver()

  Default displays "Game Over!".

### checkTime

    public boolean checkTime(int min_time,
                             int max_time,
                             int increment)

  Returns true every increment ticks, but only when gametime is between min_time and max_time.

### checkTime

    public boolean checkTime(int increment)

  Returns true every increment ticks.

### drawCount

    public void drawCount(int count,
                          java.lang.String image,
                          int x,
                          int y,
                          int increment_x)

  Draw a row of objects to indicate the value count. This is typically used to indicate lives left.

### drawWavyString

    public void drawWavyString(java.lang.String s,
                               int x,
                               int y,
                               int align,
                               int increment_x,
                               int tmr,
                               double amplitude,
                               double pos_phaseshift,
                               double timer_phaseshift,
                               java.awt.Font font,
                               java.awt.Color col)

  Draw a string with letters that move up and down individually.

### getZoomingFont

    public java.awt.Font getZoomingFont(java.awt.Font basefont,
                                        int tmr,
                                        double min_size_fac,
                                        double speed)

  Get font for zooming text in and out. Note that tmr = 0 will start the font zooming in from the farthest position.

### cycleColor

    public java.awt.Color cycleColor(java.awt.Color[] cycle,
                                     int tmr,
                                     double speed)

  Get a colour from a colour cycle.

### posWalkForwards

    public int posWalkForwards(int begin_pos,
                               int end_pos,
                               int tmr,
                               int end_time,
                               int standstill_pos,
                               int standstill_time,
                               int standstill_count)

  Walk across the screen, standing still momentarily at a specific position.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD