org.newdawn.slick
Class AppGameContainer

java.lang.Object
  extended by org.newdawn.slick.GameContainer
      extended by org.newdawn.slick.AppGameContainer
All Implemented Interfaces:
GUIContext

public class AppGameContainer
extends GameContainer

A game container that will display the game as an stand alone application.

Author:
kevin

Field Summary
protected  boolean alphaSupport
          Alpha background supported
protected  org.lwjgl.opengl.DisplayMode originalDisplayMode
          The original display mode before we tampered with things
protected  org.lwjgl.opengl.DisplayMode targetDisplayMode
          The display mode we're going to try and use
protected  boolean updateOnlyOnVisible
          True if we should update the game only when the display is visible
 
Fields inherited from class org.newdawn.slick.GameContainer
alwaysRender, clearEachFrame, forceExit, fps, game, GL, height, input, lastFPS, lastFrame, lastGame, maximumLogicInterval, minimumLogicInterval, paused, recordedFPS, running, samples, SHARED_DRAWABLE, smoothDeltas, stencil, storedDelta, supportsMultiSample, targetFPS, vsync, width
 
Constructor Summary
AppGameContainer(Game game)
          Create a new container wrapping a game
AppGameContainer(Game game, int width, int height, boolean fullscreen)
          Create a new container wrapping a game
 
Method Summary
 void destroy()
          Destroy the app game container
protected  void gameLoop()
          Strategy for overloading game loop context handling
 int getScreenHeight()
          Get the height of the standard screen resolution
 int getScreenWidth()
          Get the width of the standard screen resolution
 boolean hasFocus()
          Check if the game currently has focus
 boolean isFullscreen()
          Check if the display is in fullscreen mode
 boolean isMouseGrabbed()
          Check if the mouse cursor is current grabbed.
 boolean isUpdatingOnlyWhenVisible()
          Check if this game is only updating when visible to the user (default = true)
 void reinit()
          Renitialise the game and the context in which it's being rendered
 void setDefaultMouseCursor()
          Set the default mouse cursor - i.e.
 void setDisplayMode(int width, int height, boolean fullscreen)
          Set the display mode to be used
 void setFullscreen(boolean fullscreen)
          Indicate whether we want to be in fullscreen mode.
 void setIcon(java.lang.String ref)
          Set the icon to be displayed if possible in this type of container
 void setIcons(java.lang.String[] refs)
          Set the icons to be used for this application.
 void setMouseCursor(org.lwjgl.input.Cursor cursor, int hotSpotX, int hotSpotY)
          Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.
 void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY)
          Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.
 void setMouseCursor(Image image, int hotSpotX, int hotSpotY)
          Set the mouse cursor based on the contents of the image.
 void setMouseCursor(java.lang.String ref, int hotSpotX, int hotSpotY)
          Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.
 void setMouseGrabbed(boolean grabbed)
          Indicate whether mouse cursor should be grabbed or not
 void setTitle(java.lang.String title)
          Set the title of the window
protected  void setup()
          Setup the environment
 void setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
          Indicate if the display should update only when the game is visible (the default is true)
 void start()
          Start running the game
 boolean supportsAlphaInBackBuffer()
          Check if the display created supported alpha in the back buffer
 
Methods inherited from class org.newdawn.slick.GameContainer
enableSharedContext, enableStencil, enterOrtho, enterOrtho, exit, getAlwaysRender, getAspectRatio, getBuildVersion, getDefaultFont, getDelta, getFPS, getGraphics, getHeight, getInput, getMusicVolume, getSamples, getSharedContext, getSoundVolume, getTime, getWidth, initGL, initSystem, isMusicOn, isPaused, isShowingFPS, isSoundOn, isVSyncRequested, pause, resume, running, setAlwaysRender, setAnimatedMouseCursor, setClearEachFrame, setDefaultFont, setForceExit, setMaximumLogicUpdateInterval, setMinimumLogicUpdateInterval, setMultiSample, setMusicOn, setMusicVolume, setPaused, setShowFPS, setSmoothDeltas, setSoundOn, setSoundVolume, setTargetFrameRate, setVerbose, setVSync, sleep, supportsMultiSample, updateAndRender, updateFPS
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

originalDisplayMode

protected org.lwjgl.opengl.DisplayMode originalDisplayMode
The original display mode before we tampered with things


targetDisplayMode

protected org.lwjgl.opengl.DisplayMode targetDisplayMode
The display mode we're going to try and use


updateOnlyOnVisible

protected boolean updateOnlyOnVisible
True if we should update the game only when the display is visible


alphaSupport

protected boolean alphaSupport
Alpha background supported

Constructor Detail

AppGameContainer

public AppGameContainer(Game game)
                 throws SlickException
Create a new container wrapping a game

Parameters:
game - The game to be wrapped
Throws:
SlickException - Indicates a failure to initialise the display

AppGameContainer

public AppGameContainer(Game game,
                        int width,
                        int height,
                        boolean fullscreen)
                 throws SlickException
Create a new container wrapping a game

Parameters:
game - The game to be wrapped
width - The width of the display required
height - The height of the display required
fullscreen - True if we want fullscreen mode
Throws:
SlickException - Indicates a failure to initialise the display
Method Detail

supportsAlphaInBackBuffer

public boolean supportsAlphaInBackBuffer()
Check if the display created supported alpha in the back buffer

Returns:
True if the back buffer supported alpha

setTitle

public void setTitle(java.lang.String title)
Set the title of the window

Parameters:
title - The title to set on the window

setDisplayMode

public void setDisplayMode(int width,
                           int height,
                           boolean fullscreen)
                    throws SlickException
Set the display mode to be used

Parameters:
width - The width of the display required
height - The height of the display required
fullscreen - True if we want fullscreen mode
Throws:
SlickException - Indicates a failure to initialise the display

isFullscreen

public boolean isFullscreen()
Check if the display is in fullscreen mode

Overrides:
isFullscreen in class GameContainer
Returns:
True if the display is in fullscreen mode

setFullscreen

public void setFullscreen(boolean fullscreen)
                   throws SlickException
Indicate whether we want to be in fullscreen mode. Note that the current display mode must be valid as a fullscreen mode for this to work

Overrides:
setFullscreen in class GameContainer
Parameters:
fullscreen - True if we want to be in fullscreen mode
Throws:
SlickException - Indicates we failed to change the display mode

setMouseCursor

public void setMouseCursor(java.lang.String ref,
                           int hotSpotX,
                           int hotSpotY)
                    throws SlickException
Description copied from class: GameContainer
Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.

Specified by:
setMouseCursor in interface GUIContext
Specified by:
setMouseCursor in class GameContainer
Parameters:
ref - The location of the image to be loaded for the cursor
hotSpotX - The x coordinate of the hotspot within the cursor image
hotSpotY - The y coordinate of the hotspot within the cursor image
Throws:
SlickException - Indicates a failure to load the cursor image or create the hardware cursor
See Also:
GameContainer.setMouseCursor(java.lang.String, int, int)

setMouseCursor

public void setMouseCursor(ImageData data,
                           int hotSpotX,
                           int hotSpotY)
                    throws SlickException
Description copied from class: GameContainer
Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.

Specified by:
setMouseCursor in interface GUIContext
Specified by:
setMouseCursor in class GameContainer
Parameters:
data - The image data from which the cursor can be construted
hotSpotX - The x coordinate of the hotspot within the cursor image
hotSpotY - The y coordinate of the hotspot within the cursor image
Throws:
SlickException - Indicates a failure to load the cursor image or create the hardware cursor
See Also:
GameContainer.setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)

setMouseCursor

public void setMouseCursor(org.lwjgl.input.Cursor cursor,
                           int hotSpotX,
                           int hotSpotY)
                    throws SlickException
Description copied from class: GameContainer
Set the mouse cursor to be displayed - this is a hardware cursor and hence shouldn't have any impact on FPS.

Specified by:
setMouseCursor in interface GUIContext
Specified by:
setMouseCursor in class GameContainer
Parameters:
cursor - The cursor to use
hotSpotX - The x coordinate of the hotspot within the cursor image
hotSpotY - The y coordinate of the hotspot within the cursor image
Throws:
SlickException - Indicates a failure to load the cursor image or create the hardware cursor
See Also:
GameContainer.setMouseCursor(org.lwjgl.input.Cursor, int, int)

setMouseCursor

public void setMouseCursor(Image image,
                           int hotSpotX,
                           int hotSpotY)
                    throws SlickException
Description copied from class: GameContainer
Set the mouse cursor based on the contents of the image. Note that this will not take account of render state type changes to images (rotation and such). If these effects are required it is recommended that an offscreen buffer be used to produce an appropriate image. An offscreen buffer will always be used to produce the new cursor and as such this operation an be very expensive

Specified by:
setMouseCursor in class GameContainer
Parameters:
image - The image to use as the cursor
hotSpotX - The x coordinate of the hotspot within the cursor image
hotSpotY - The y coordinate of the hotspot within the cursor image
Throws:
SlickException - Indicates a failure to load the cursor image or create the hardware cursor
See Also:
GameContainer.setMouseCursor(org.newdawn.slick.Image, int, int)

reinit

public void reinit()
            throws SlickException
Description copied from class: GameContainer
Renitialise the game and the context in which it's being rendered

Overrides:
reinit in class GameContainer
Throws:
SlickException - Indicates a failure rerun initialisation routines
See Also:
GameContainer.reinit()

start

public void start()
           throws SlickException
Start running the game

Throws:
SlickException - Indicates a failure to initialise the system

setup

protected void setup()
              throws SlickException
Setup the environment

Throws:
SlickException - Indicates a failure

gameLoop

protected void gameLoop()
                 throws SlickException
Strategy for overloading game loop context handling

Throws:
SlickException - Indicates a game failure

setUpdateOnlyWhenVisible

public void setUpdateOnlyWhenVisible(boolean updateOnlyWhenVisible)
Description copied from class: GameContainer
Indicate if the display should update only when the game is visible (the default is true)

Overrides:
setUpdateOnlyWhenVisible in class GameContainer
Parameters:
updateOnlyWhenVisible - True if we should updated only when the display is visible
See Also:
GameContainer.setUpdateOnlyWhenVisible(boolean)

isUpdatingOnlyWhenVisible

public boolean isUpdatingOnlyWhenVisible()
Description copied from class: GameContainer
Check if this game is only updating when visible to the user (default = true)

Overrides:
isUpdatingOnlyWhenVisible in class GameContainer
Returns:
True if the game is only updated when the display is visible
See Also:
GameContainer.isUpdatingOnlyWhenVisible()

setIcon

public void setIcon(java.lang.String ref)
             throws SlickException
Description copied from class: GameContainer
Set the icon to be displayed if possible in this type of container

Specified by:
setIcon in class GameContainer
Parameters:
ref - The reference to the icon to be displayed
Throws:
SlickException - Indicates a failure to load the icon
See Also:
GameContainer.setIcon(java.lang.String)

setMouseGrabbed

public void setMouseGrabbed(boolean grabbed)
Description copied from class: GameContainer
Indicate whether mouse cursor should be grabbed or not

Specified by:
setMouseGrabbed in class GameContainer
Parameters:
grabbed - True if mouse cursor should be grabbed
See Also:
GameContainer.setMouseGrabbed(boolean)

isMouseGrabbed

public boolean isMouseGrabbed()
Description copied from class: GameContainer
Check if the mouse cursor is current grabbed. This will cause it not to be seen.

Specified by:
isMouseGrabbed in class GameContainer
Returns:
True if the mouse is currently grabbed
See Also:
GameContainer.isMouseGrabbed()

hasFocus

public boolean hasFocus()
Description copied from class: GameContainer
Check if the game currently has focus

Specified by:
hasFocus in class GameContainer
Returns:
True if the game currently has focus
See Also:
GameContainer.hasFocus()

getScreenHeight

public int getScreenHeight()
Description copied from class: GameContainer
Get the height of the standard screen resolution

Specified by:
getScreenHeight in interface GUIContext
Specified by:
getScreenHeight in class GameContainer
Returns:
The screen height
See Also:
GameContainer.getScreenHeight()

getScreenWidth

public int getScreenWidth()
Description copied from class: GameContainer
Get the width of the standard screen resolution

Specified by:
getScreenWidth in interface GUIContext
Specified by:
getScreenWidth in class GameContainer
Returns:
The screen width
See Also:
GameContainer.getScreenWidth()

destroy

public void destroy()
Destroy the app game container


setIcons

public void setIcons(java.lang.String[] refs)
              throws SlickException
Description copied from class: GameContainer
Set the icons to be used for this application. Note that the size of the icon defines how it will be used. Important ones to note Windows window icon must be 16x16 Windows alt-tab icon must be 24x24 or 32x32 depending on Windows version (XP=32)

Specified by:
setIcons in class GameContainer
Parameters:
refs - The reference to the icon to be displayed
Throws:
SlickException - Indicates a failure to load the icon
See Also:
GameContainer.setIcons(java.lang.String[])

setDefaultMouseCursor

public void setDefaultMouseCursor()
Description copied from class: GameContainer
Set the default mouse cursor - i.e. the original cursor before any native cursor was set

Specified by:
setDefaultMouseCursor in interface GUIContext
Specified by:
setDefaultMouseCursor in class GameContainer
See Also:
GameContainer.setDefaultMouseCursor()


Copyright © 2006 New Dawn Software. All Rights Reserved.