|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JGEngineInterface
Interface defining all platform-independent methods in JGEngine. It is primarily used as an internal interface for JGObjects, JGTimers, etc to the different engine implementations.
Field Summary | |
---|---|
static int |
CROSSHAIR_CURSOR
Platform-independent cursor. |
static int |
DEFAULT_CURSOR
Platform-independent cursor. |
static int |
HAND_CURSOR
Platform-independent cursor. |
static java.lang.String |
JGameVersionString
|
static int |
KeyAlt
|
static int |
KeyBackspace
|
static int |
KeyCtrl
|
static int |
KeyDown
Cursor keys for both regular and mobile keyboard. |
static int |
KeyEnter
On a mobile, pressing "*" also triggers KeyEnter. |
static int |
KeyEsc
|
static int |
KeyFire
Fire stands for a mobile key, indicating the fire button of the cursor controls. |
static int |
KeyLeft
Cursor keys for both regular and mobile keyboard. |
static int |
KeyMouse1
Keymap equivalent of mouse button. |
static int |
KeyMouse2
Keymap equivalent of mouse button. |
static int |
KeyMouse3
Keymap equivalent of mouse button. |
static int |
KeyPound
The mobile Pound key, equal to '#'. |
static int |
KeyRight
Cursor keys for both regular and mobile keyboard. |
static int |
KeyShift
On a mobile, the cursor control Fire is the same as shift. |
static int |
KeyStar
The mobile Star key, equal to '*'. |
static int |
KeyTab
|
static int |
KeyUp
Cursor keys for both regular and mobile keyboard. |
static int |
NO_CURSOR
Platform-independent cursor. |
static int |
WAIT_CURSOR
Platform-independent cursor. |
Method Summary | |
---|---|
void |
addGameState(java.lang.String state)
Add the given state to the game's existing state on the next frame. |
boolean |
and(int value,
int mask)
A Boolean AND shorthand to use for collision; returns (value&mask) != 0. |
void |
andTileCid(int x,
int y,
int and_mask)
Modify the cid of a single tile by ANDing a bit mask, leaving the actual tile. |
double |
atan2(double y,
double x)
Replacement for Math.atan2 for the sake of MIDP portability. |
void |
checkBGCollision(int tilecid,
int objcid)
Calls all bg colliders of objects that match objid that collide with tiles that match tileid. |
int |
checkBGCollision(JGRectangle r)
Check collision of tiles within given rectangle, return the OR of all cids found. |
void |
checkCollision(int srccid,
int dstcid)
Calls all colliders of objects that match dstcid that collide with objects that match srccid. |
int |
checkCollision(int cidmask,
JGObject obj)
Checks collision of objects with given cid mask with given object. |
void |
clearGameState()
Set the game's main state to none, on the next frame. |
void |
clearKey(int key)
Set the key status of a key to released. |
void |
clearLastKey()
Clear the lastkey status. |
void |
clearMouseButton(int nr)
Set state of button to released. |
int |
countObjects(java.lang.String prefix,
int cidmask)
Count how many objects there are with both the given name prefix and have colid&cidmask != 0. |
int |
countObjects(java.lang.String prefix,
int cidmask,
boolean suspended_obj)
Count how many objects there are with both the given name prefix and have colid&cidmask != 0. |
int |
countTiles(int tilecidmask)
Count number of tiles with given mask. |
java.lang.String |
dbgExceptionToString(java.lang.Throwable e)
Convert the relevant information of an exception to a multiline String. |
void |
dbgPrint(java.lang.String msg)
Print a debug message, with the main program being the source. |
void |
dbgPrint(java.lang.String source,
java.lang.String msg)
Print a debug message from a specific source, which is either the main program or a JGObject. |
void |
dbgSetDebugColor1(JGColor col)
Set debug color 1, used for printing debug information. |
void |
dbgSetDebugColor2(JGColor col)
Set debug color 2, used for printing debug information. |
void |
dbgSetMessageExpiry(int ticks)
Set the number of frames a debug message of a removed object should remain on the playfield. |
void |
dbgSetMessageFont(JGFont font)
Set the font for displaying debug messages. |
void |
dbgShowBoundingBox(boolean enabled)
Show bounding boxes around the objects: the image bounding box (getBBox) , the tile span (getTiles), and the center tiles (getCenterTiles). |
void |
dbgShowException(java.lang.String source,
java.lang.Throwable e)
Print the relevant information of an exception as a debug message. |
void |
dbgShowFullStackTrace(boolean enabled)
Indicates whether to show full exception stack traces or just the first lines. |
void |
dbgShowGameState(boolean enabled)
Show the game state in the bottom right corner of the screen. |
void |
dbgShowMessagesInPf(boolean enabled)
Output messages on playfield instead of console. |
void |
defineAnimation(java.lang.String id,
java.lang.String[] frames,
double speed)
Define new animation sequence. |
void |
defineAnimation(java.lang.String id,
java.lang.String[] frames,
double speed,
boolean pingpong)
Define new animation sequence. |
void |
defineAudioClip(java.lang.String clipid,
java.lang.String filename)
Associate given clipid with a filename. |
void |
defineImage(java.lang.String imgname,
java.lang.String tilename,
int collisionid,
java.lang.String imgmap,
int mapidx,
java.lang.String img_op)
Define new sprite/tile image from map, with collision bounding box equal to the image's dimensions. |
void |
defineImage(java.lang.String imgname,
java.lang.String tilename,
int collisionid,
java.lang.String imgmap,
int mapidx,
java.lang.String img_op,
int top,
int left,
int width,
int height)
Define new sprite/tile image from map. |
void |
defineImage(java.lang.String imgname,
java.lang.String tilename,
int collisionid,
java.lang.String imgfile,
java.lang.String img_op)
Define new sprite/tile image from a file, with collision bounding box equal to the image's dimensions. |
void |
defineImage(java.lang.String name,
java.lang.String tilename,
int collisionid,
java.lang.String imgfile,
java.lang.String img_op,
int top,
int left,
int width,
int height)
Define new sprite/tile image from a file. |
void |
defineImageMap(java.lang.String mapname,
java.lang.String imgfile,
int xofs,
int yofs,
int tilex,
int tiley,
int skipx,
int skipy)
Define image map, a large image containing a number of smaller images to use for sprites or fonts. |
void |
defineImageRotated(java.lang.String imgname,
java.lang.String tilename,
int collisionid,
java.lang.String srcimg,
double angle)
Define new image by rotating an already loaded image. |
void |
defineMedia(java.lang.String filename)
Load a set of imagemap, image, animation, and audio clip definitions from a file. |
void |
destroy()
Destroy function for deinitialising the engine properly. |
void |
destroyApp(boolean unconditional)
Called by the application manager to exit app. |
void |
disableAudio()
Disable audio, stop all currently playing audio. |
int |
displayHeight()
Get the real display height on this device. |
int |
displayWidth()
Get the real display width on this device. |
void |
doFrame()
Is called every frame. |
void |
drawImage(double x,
double y,
java.lang.String imgname)
Draw image with given ID. |
void |
drawImage(double x,
double y,
java.lang.String imgname,
boolean pf_relative)
Draw image with given ID. |
void |
drawImage(double x,
double y,
java.lang.String imgname,
JGColor blend_col,
double alpha,
double rot,
double scale,
boolean pf_relative)
Extended version of drawImage for OpenGL or Android. |
void |
drawImage(java.lang.String imgname,
double x,
double y)
Draw image with given ID, new version. |
void |
drawImage(java.lang.String imgname,
double x,
double y,
boolean pf_relative)
Draw image with given ID, new version. |
void |
drawImage(java.lang.String imgname,
double x,
double y,
boolean pf_relative,
JGColor blend_col,
double alpha,
double rot,
double scale)
Extended version of drawImage for OpenGL or Android, new version. |
void |
drawImageString(java.lang.String string,
double x,
double y,
int align,
java.lang.String imgmap,
int char_offset,
int spacing)
Draws a single line of text using an image map as font; text alignment is same as drawString. |
void |
drawImageString(java.lang.String string,
double x,
double y,
int align,
java.lang.String imgmap,
int char_offset,
int spacing,
boolean pf_relative)
Draws a single line of text using an image map as font; text alignment is same as drawString. |
void |
drawLine(double x1,
double y1,
double x2,
double y2)
Draw a line with current thickness and colour. |
void |
drawLine(double x1,
double y1,
double x2,
double y2,
boolean pf_relative)
Draw a line with current thickness and colour. |
void |
drawLine(double x1,
double y1,
double x2,
double y2,
double thickness,
JGColor color)
DrawLine combined with thickness/colour setting. |
void |
drawOval(double x,
double y,
double width,
double height,
boolean filled,
boolean centered)
Draw oval with default thickness and colour. |
void |
drawOval(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
boolean pf_relative)
Draw oval with default thickness and colour. |
void |
drawOval(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
double thickness,
JGColor color)
Set thickness/colour and draw oval. |
void |
drawPolygon(double[] x,
double[] y,
JGColor[] col,
int len,
boolean filled,
boolean pf_relative)
Draw convex polygon. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean filled,
boolean centered)
Draw rectangle in default colour and thickness. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
boolean pf_relative)
Draw rectangle in default colour and thickness. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
boolean pf_relative,
JGColor[] shadecol)
Draw shaded rectangle. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
boolean pf_relative,
JGColor[] shadecol,
java.lang.String tileimage)
Draw shaded or patterned rectangle. |
void |
drawRect(double x,
double y,
double width,
double height,
boolean filled,
boolean centered,
double thickness,
JGColor color)
Set colour/thickness and draw rectangle. |
void |
drawString(java.lang.String str,
double x,
double y,
int align)
Draws string so that (x,y) is the topleft coordinate (align=-1), the top middle coordinate (align=0), or the top right coordinate (align=1). |
void |
drawString(java.lang.String str,
double x,
double y,
int align,
boolean pf_relative)
Draws string so that (x,y) is the topleft coordinate (align=-1), the top middle coordinate (align=0), or the top right coordinate (align=1). |
void |
drawString(java.lang.String str,
double x,
double y,
int align,
JGFont font,
JGColor color)
Draws string so that (x,y) is the topleft coordinate (align=-1), the top middle coordinate (align=0), or the top right coordinate (align=1). |
void |
drawTile(int xi,
int yi,
int tileid)
Draw tile directly on background, do not call this directly, use setTile instead. |
void |
enableAudio()
Enable audio, restart any audio loops. |
boolean |
existsObject(java.lang.String index)
Get object if it exists. |
void |
exitEngine(java.lang.String msg)
Exit, optionally reporting an exit message. |
void |
fillBG(java.lang.String filltile)
Fill the background with the given tile. |
double[] |
getAccelVec()
get double[3] vector representing acceleration |
double |
getAccelX()
get accelerometer vector X coordinate |
double |
getAccelY()
get accelerometer vector Y coordinate |
double |
getAccelZ()
get accelerometer vector Z coordinate (positive = towards user) |
Animation |
getAnimation(java.lang.String id)
Get animation definition, don't call directly. |
java.lang.String |
getConfigPath(java.lang.String filename)
Returns path to writable location for a file with the given name. |
double |
getFontHeight(JGFont font)
Get height of given font in pixels. |
double |
getFrameRate()
|
double |
getFrameSkip()
|
double |
getGameSpeed()
Get game speed variable. |
JGImage |
getImage(java.lang.String imgname)
Gets (scaled) image directly. |
JGRectangle |
getImageBBox(java.lang.String imgname)
Gets the collision bounding box of an image. |
JGPoint |
getImageSize(java.lang.String imgname)
Gets (non-scaled) image's physical size directly. |
boolean |
getKey(int key)
Get the key status of the given key. |
int |
getKeyCode(java.lang.String keydesc)
Obtain key code from printable string describing the key, the inverse of getKeyDesc. |
java.lang.String |
getKeyDesc(int key)
Get a printable string describing the key. |
int |
getLastKey()
Get the keycode of the key that was pressed last, 0=none. |
char |
getLastKeyChar()
Get the keycode of the key that was pressed last, 0=none. |
double |
getMinScaleFactor()
Get minimum of the x and y scale factors |
boolean |
getMouseButton(int nr)
Get state of button. |
boolean |
getMouseInside()
Check if mouse is inside game window |
JGPoint |
getMousePos()
Get current mouse position in logical coordinates, inverse projected through last set view zoom/rotate setting. |
int |
getMouseX()
Get current mouse X position |
int |
getMouseY()
Get current mouse Y position |
JGObject |
getObject(java.lang.String index)
Get object if it exists, null if not. |
java.util.Vector |
getObjects(java.lang.String prefix,
int cidmask,
boolean suspended_obj,
JGRectangle bbox)
Query the object list for objects matching the given name prefix, CID mask, and collide with the given bounding box. |
int |
getOffscreenMarginX()
Get offscreen X margin. |
int |
getOffscreenMarginY()
Get offscreen Y margin. |
int |
getTileCid(int xidx,
int yidx)
Get collision id of tile at given tile index position. |
int |
getTileCid(JGPoint center,
int xofs,
int yofs)
Get the tile cid of the point that is (xofs,yofs) from the tile index coordinate center. |
int |
getTileCid(JGRectangle tiler)
Get the OR of the cids at the tile indexes given by tiler |
int |
getTileCidAtCoord(double x,
double y)
Get collision id of the tile at given pixel coordinates. |
JGPoint |
getTileCoord(int tilex,
int tiley)
Get pixel coordinate corresponding to the top left of the tile at the given index |
JGPoint |
getTileCoord(JGPoint tileidx)
Get pixel coordinate corresponding to the top left of the tile at the given index |
JGPoint |
getTileIndex(double x,
double y)
Get tile index of the tile the coordinate is on. |
JGRectangle |
getTiles(JGRectangle r)
Get tile index range of all tiles overlapping given rectangle of pixel coordinates. |
boolean |
getTiles(JGRectangle dest,
JGRectangle r)
Get tile index range of all tiles overlapping given rectangle of pixel coordinates, version without object creation. |
java.lang.String |
getTileStr(int xidx,
int yidx)
get string id of tile at given index position. |
java.lang.String |
getTileStr(JGPoint center,
int xofs,
int yofs)
Get the tile string of the point that is (xofs,yofs) from the tile index coordinate center. |
java.lang.String |
getTileStrAtCoord(double x,
double y)
Get string id of the tile at given pixel coordinates. |
boolean |
getVideoSyncedUpdate()
|
double |
getXAlignOfs(double x)
Returns the difference between position and the closest tile-aligned position. |
double |
getXDist(double x1,
double x2)
Calculates length of the shortest path between x1 and x2, with x1, x2 being playfield coordinates, taking into account the wrap setting. |
double |
getXScaleFactor()
Get scale factor of real screen width wrt virtual screen width |
double |
getYAlignOfs(double y)
Returns the difference between position and the closest tile-aligned position. |
double |
getYDist(double y1,
double y2)
Calculates length of the shortest path between y1 and y2, with y1, y2 being playfield coordinates, taking into account the wrap setting. |
double |
getYScaleFactor()
Get scale factor of real screen height wrt virtual screen height |
boolean |
hasAccelerometer()
returns true if device has accelerometer (currently only android) |
boolean |
inGameState(java.lang.String state)
Check if game is in given state. |
boolean |
inGameStateNextFrame(java.lang.String state)
Check if game will be in given state the next frame. |
void |
initCanvas()
Override to define your own initialisations before the engine initialises. |
void |
initEngine(int width,
int height)
Init engine as application. |
void |
initEngineApplet()
Init engine as applet; call this in your engine constructor. |
void |
initEngineComponent(int width,
int height)
Init engine as component to be embedded in a frame or panel; call this in your engine constructor. |
void |
initGame()
Override to define your own initialisations after the engine initialised. |
int |
invokeUrl(java.lang.String url,
java.lang.String target)
Execute or go to URL (action depends on file type). |
boolean |
isAndroid()
Are we running on Android? |
boolean |
isApplet()
Are we running as an applet or as an application? |
boolean |
isMidlet()
Are we running as a midlet? |
boolean |
isOpenGL()
Are we running with an OpenGL backend? |
boolean |
isRunning()
True if engine is running, false if paused. |
boolean |
isXAligned(double x,
double margin)
Returns true if x falls within margin of the tile snap grid. |
boolean |
isYAligned(double y,
double margin)
Returns true if y falls within margin of the tile snap grid. |
java.lang.String |
lastPlayedAudio(java.lang.String channel)
Returns the audioclip that was last played, null if audio was stopped with stopAudio. |
void |
markAddObject(JGObject obj)
Add new object, will become active next frame, do not call directly. |
double |
moduloXPos(double x)
A modulo that moduloes symmetrically, relative to the middle of the view. |
double |
moduloYPos(double y)
A modulo that moduloes symmetrically, relative to the middle of the view. |
void |
moveObjects()
Call the move() methods of all registered objects. |
void |
moveObjects(java.lang.String prefix,
int cidmask)
Call the move() methods of those objects matching the given name prefix and collision id mask. |
void |
optsAddBoolean(java.lang.String varname,
java.lang.String title,
java.lang.String desc,
boolean initial)
Adds boolean that can be configured with a checkbox. |
void |
optsAddEnum(java.lang.String varname,
java.lang.String title,
java.lang.String desc,
java.lang.String[] values,
int initial)
Adds enum that can be configured with radio buttons. |
void |
optsAddKey(java.lang.String varname,
java.lang.String title,
java.lang.String desc,
int initial)
Adds "key" option that can be configured by selecting a key or button on the device. |
void |
optsAddNumber(java.lang.String varname,
java.lang.String title,
java.lang.String desc,
int decimals,
double lower,
double upper,
double step,
double initial)
adds (int or float) number that can be configured with a slider. |
void |
optsAddString(java.lang.String varname,
java.lang.String title,
java.lang.String desc,
int maxlen,
boolean isPassword,
java.lang.String initial)
Adds String that can be configured by typing text. |
void |
optsAddTitle(java.lang.String title)
Adds title to be displayed above subsequent items. |
void |
optsClear()
Clear all previous option definitions. |
void |
orTileCid(int x,
int y,
int or_mask)
Modify the cid of a single tile by ORing a bit mask, leaving the actual tile. |
void |
paintFrame()
Is called when the engine's default screen painting is finished, and custom painting actions may be carried out. |
void |
pauseApp()
Called by the application manager to pause app. |
int |
pfHeight()
Get the virtual height in pixels (not the scaled screen height) |
int |
pfTilesX()
Get the number of tiles in X direction |
int |
pfTilesY()
Get the number of tiles in Y direction |
int |
pfWidth()
Get the virtual width in pixels (not the scaled screen width) |
boolean |
pfWrapX()
Is playfield X wrap enabled? |
boolean |
pfWrapY()
Is playfield Y wrap enabled? |
void |
playAudio(java.lang.String clipid)
Play audio clip on unnamed channel, which means it will not replace another clip, and cannot be stopped. |
void |
playAudio(java.lang.String channel,
java.lang.String clipid,
boolean loop)
Play clip on channel with given name. |
double |
random(double min,
double max)
A floating-point random number between min and max |
double |
random(double min,
double max,
double interval)
Generates discrete random number between min and max inclusive, with steps of interval. |
int |
random(int min,
int max,
int interval)
Generates discrete random number between min and max inclusive, with steps of interval, integer version. |
void |
registerTimer(JGTimer timer)
Register a timer with the engine, don't call directly. |
void |
removeAllTimers()
Remove all JGTimers still ticking in the system. |
void |
removeGameState(java.lang.String state)
Remove the given state from the game's existing state on the next frame. |
void |
removeObject(JGObject obj)
Remove one particular object. |
void |
removeObjects(java.lang.String prefix,
int cidmask)
Remove all objects which have the given name prefix and/or match the given cidmask. |
void |
removeObjects(java.lang.String prefix,
int cidmask,
boolean suspended_obj)
Remove all objects which have the given name prefix and/or match the given cidmask. |
void |
requestGameFocus()
Call this to get focus. |
void |
setAuthorMessage(java.lang.String msg)
Set author message, default "JGame [version]" |
void |
setBGColor(JGColor bgcolor)
Set global background colour, which is displayed in borders, and behind transparent tiles if no BGImage is defined. |
void |
setBGImage(int depth,
java.lang.String bgimg,
boolean wrapx,
boolean wrapy)
Set image to display at a particular parallax scroll level. |
void |
setBGImage(java.lang.String bgimg)
Set image to display behind transparent tiles. |
void |
setBGImgOffset(int depth,
double xofs,
double yofs,
boolean centered)
Change (absolute) offset of BG image independently of view offset. |
void |
setBlendMode(int src_func,
int dst_func)
Set blend mode, for platforms that support blending. |
void |
setCanvasSettings(int nrtilesx,
int nrtilesy,
int tilex,
int tiley,
JGColor fgcolor,
JGColor bgcolor,
JGFont msgfont)
Set canvas dimensions and message colours/fonts. |
void |
setColor(JGColor col)
Set current drawing colour. |
void |
setColorsFont(JGColor fgcolor,
JGColor bgcolor,
JGFont msgfont)
Set foreground and background colour, and message font in one go; passing a null means ignore that argument. |
void |
setFGColor(JGColor fgcolor)
Set global foreground colour, used for printing text and status messages. |
void |
setFont(JGFont font)
Set current font, scale the font to screen size. |
void |
setFrameRate(double fps,
double maxframeskip)
Set frame rate in frames per second, and maximum number of frames that may be skipped before displaying a frame again. |
void |
setGameSpeed(double speed)
Set game speed variable, default is 1.0. |
void |
setGameState(java.lang.String state)
Set the game's main state on the next frame. |
void |
setKey(int key)
Set the key status of a key to pressed. |
void |
setMouseButton(int nr)
Set state of button to pressed. |
void |
setMouseCursor(int cursor)
Set mouse cursor to a platform-independent standard cursor. |
void |
setMouseCursor(java.lang.Object cursor)
Set mouse cursor, platform dependent. |
void |
setMsgFont(JGFont msgfont)
Set the (unscaled) message font, used for displaying status messages. |
void |
setOffscreenMargin(int xmargin,
int ymargin)
Set margin used for testing if object should expire or suspend when off-view or off-playfield. |
void |
setPFSize(int nrtilesx,
int nrtilesy)
Set the playfield size to be any size larger or equal to the view size. |
void |
setPFWrap(boolean wrapx,
boolean wrapy,
int shiftx,
int shifty)
Set playfield wraparound setting. |
void |
setProgressBar(double pos)
Set progress bar position in the load screen. |
void |
setProgressMessage(java.lang.String msg)
Set progress message, default "Loading files..." |
void |
setRenderSettings(int alpha_thresh,
JGColor render_bg_col)
Configure image rendering. |
void |
setScalingPreferences(double min_aspect_ratio,
double max_aspect_ratio,
int crop_top,
int crop_left,
int crop_bottom,
int crop_right)
Set scaling preferences for translating the virtual playfield to the actual display. |
void |
setSmoothing(boolean smooth_magnify)
Magnification can be set to smooth or blocky. |
void |
setStroke(double thickness)
Set the line thickness |
void |
setTextOutline(int thickness,
JGColor colour)
Set parameters of outline surrounding text (for example, used to increase contrast). |
void |
setTile(int x,
int y,
java.lang.String tilestr)
Set a single tile. |
void |
setTile(JGPoint tileidx,
java.lang.String tilename)
Set a single tile. |
void |
setTileCid(int x,
int y,
int value)
Set the cid of a single tile to the given value, leaving the actual tile. |
void |
setTileCid(int x,
int y,
int and_mask,
int or_mask)
Set the cid of a single tile using and and or mask. |
void |
setTiles(int xofs,
int yofs,
java.lang.String[] tilemap)
Set a block of tiles according to the single-letter tile names in the nxm character array tilemap. |
void |
setTileSettings(java.lang.String out_of_bounds_tile,
int out_of_bounds_cid,
int preserve_cids)
Define background tile settings. |
void |
setTilesMulti(int xofs,
int yofs,
java.lang.String[] tilemap)
Set a block of tiles according to the tile names in the nxm element array tilemap. |
void |
setVideoSyncedUpdate(boolean value)
Enable/disable video synced update (jogl only). |
void |
setViewOffset(int xofs,
int yofs,
boolean centered)
Change offset of playfield view. |
void |
setViewZoomRotate(double zoom,
double rotate)
Zoom/rotate view. |
void |
snapToGrid(JGPoint p,
int gridsnapx,
int gridsnapy)
Snap p to grid in case p is close enough to the grid lines. |
double |
snapToGridX(double x,
double gridsnapx)
Snap to grid, double version. |
double |
snapToGridY(double y,
double gridsnapy)
Snap to grid, double version. |
void |
start()
Signal that the engine should start running. |
void |
startApp()
Called when midlet is first initialised, or unpaused. |
void |
stop()
signal that the engine should stop running and wait. |
void |
stopAudio()
Stop all audio channels. |
void |
stopAudio(java.lang.String channel)
Stop one audio channel. |
boolean |
storeExists(java.lang.String id)
Checks if item exists in store |
double |
storeReadDouble(java.lang.String id,
double undef)
Reads double from store, use undef if ID not found |
int |
storeReadInt(java.lang.String id,
int undef)
Reads int from store, use undef if ID not found |
java.lang.String |
storeReadString(java.lang.String id,
java.lang.String undef)
Reads String from store, use undef if ID not found |
void |
storeRemove(java.lang.String id)
Remove record if it exists |
void |
storeWriteDouble(java.lang.String id,
double value)
Writes double to store under given ID |
void |
storeWriteInt(java.lang.String id,
int value)
Writes integer to store under given ID |
void |
storeWriteString(java.lang.String id,
java.lang.String value)
Writes string to store under given ID |
int |
tileHeight()
Get the tile height in (virtual) pixels. |
java.lang.String |
tileIDToStr(int tileid)
Convert tile ID code to tile name (as used internally). |
int |
tileStrToID(java.lang.String tilestr)
Convert tile name to integer ID code (as used internally). |
int |
tileWidth()
Get the tile width in (virtual) pixels. |
int |
viewHeight()
Get the virtual height in pixels (not the scaled screen height) |
int |
viewTilesX()
Get the number of tiles of view window in X direction |
int |
viewTilesY()
Get the number of tiles of view window in Y direction |
int |
viewWidth()
Get the virtual width in pixels (not the scaled screen width) |
int |
viewXOfs()
Get view offset as it will be at the next frame draw, in case we are not inside a frame draw, or the view offset as it is, when we are. |
int |
viewYOfs()
Get view offset as it will be at the next frame draw, in case we are not inside a frame draw, or the view offset as it is, when we are. |
void |
wakeUpOnKey(int key)
Make engine call start() when a key is pressed. |
Field Detail |
---|
static final java.lang.String JGameVersionString
static final int KeyUp
static final int KeyDown
static final int KeyLeft
static final int KeyRight
static final int KeyShift
static final int KeyFire
static final int KeyCtrl
static final int KeyAlt
static final int KeyEsc
static final int KeyEnter
static final int KeyStar
static final int KeyPound
static final int KeyBackspace
static final int KeyTab
static final int KeyMouse1
static final int KeyMouse2
static final int KeyMouse3
static final int NO_CURSOR
static final int DEFAULT_CURSOR
static final int CROSSHAIR_CURSOR
static final int HAND_CURSOR
static final int WAIT_CURSOR
Method Detail |
---|
void setProgressBar(double pos)
pos
- a number between 0 and 1void setProgressMessage(java.lang.String msg)
void setAuthorMessage(java.lang.String msg)
JGImage getImage(java.lang.String imgname)
JGPoint getImageSize(java.lang.String imgname)
void defineImage(java.lang.String name, java.lang.String tilename, int collisionid, java.lang.String imgfile, java.lang.String img_op, int top, int left, int width, int height)
name
- image idtilename
- tile id (1-4 characters)collisionid
- cid to use for tile collision matchingimgfile
- filespec in resource path; "null" means no filetop
- collision bounding box dimensionsleft
- collision bounding box dimensionswidth
- collision bounding box dimensionsheight
- collision bounding box dimensionsvoid defineImageRotated(java.lang.String imgname, java.lang.String tilename, int collisionid, java.lang.String srcimg, double angle)
If an image with this id is already defined, it is removed from any caches, so that the old image is really unloaded. This can be used to load large (background) images on demand, rather than have them all in memory. Note that the unloading does not work for images defined from image maps.
imgname
- image idtilename
- tile id (1-4 characters)collisionid
- cid to use for tile collision matchingsrcimg
- image id of (already loaded) source imageangle
- the angle in radians by which to rotatevoid defineImageMap(java.lang.String mapname, java.lang.String imgfile, int xofs, int yofs, int tilex, int tiley, int skipx, int skipy)
mapname
- id of image mapimgfile
- filespec in resource pathxofs
- x offset of first imageyofs
- y offset of first imagetilex
- width of an imagetiley
- height of an imageskipx
- nr of pixels to skip between successive imagesskipy
- nr of pixels to skip between successive images vertically.JGRectangle getImageBBox(java.lang.String imgname)
void defineImage(java.lang.String imgname, java.lang.String tilename, int collisionid, java.lang.String imgfile, java.lang.String img_op)
imgname
- image idtilename
- tile id (1-4 characters)collisionid
- cid to use for tile collision matchingimgfile
- filespec in resource path; "null" means no filevoid defineImage(java.lang.String imgname, java.lang.String tilename, int collisionid, java.lang.String imgmap, int mapidx, java.lang.String img_op, int top, int left, int width, int height)
imgname
- image idtilename
- tile id (1-4 characters)collisionid
- cid to use for tile collision matchingimgmap
- id of image mapmapidx
- index of image in map, 0=firsttop
- collision bounding box dimensionsleft
- collision bounding box dimensionswidth
- collision bounding box dimensionsheight
- collision bounding box dimensionsvoid defineImage(java.lang.String imgname, java.lang.String tilename, int collisionid, java.lang.String imgmap, int mapidx, java.lang.String img_op)
imgname
- image idtilename
- tile id (1-4 characters)collisionid
- cid to use for tile collision matchingimgmap
- id of image mapmapidx
- index of image in map, 0=firstvoid defineMedia(java.lang.String filename)
defineImage("mytile", "#", 1,"gfx/myimage.gif", "-");
is equivalent to the following line in the table:
mytile # 1
gfx/myimage.gif -
with the whitespace between the fields consisting of one or more tabs. The defineAnimation methods take an array of names as the second argument. This is represented in table format as the names separated by semicolon ';' characters. So:
defineAnimation("anim",new String[]{"frame0","frame1",...},0.5);
is equivalent to:
anim frame0;frame1;... 0.5
void setBGImage(java.lang.String bgimg)
bgimg
- image name, null=turn off background imagevoid setBGImage(int depth, java.lang.String bgimg, boolean wrapx, boolean wrapy)
bgimg
- image name, null=turn off image at this leveldepth
- depth level, 0=topmostwrapx
- image should wrap in x directionwrapy
- image should wrap in y directionvoid setTileSettings(java.lang.String out_of_bounds_tile, int out_of_bounds_cid, int preserve_cids)
out_of_bounds_tile
- tile string to use outside of screen boundsout_of_bounds_cid
- cid to use outside of screen boundariespreserve_cids
- cid mask to preserve when setting tilesvoid fillBG(java.lang.String filltile)
filltile
- null means use background colourvoid markAddObject(JGObject obj)
boolean existsObject(java.lang.String index)
JGObject getObject(java.lang.String index)
void moveObjects(java.lang.String prefix, int cidmask)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignorevoid moveObjects()
void checkCollision(int srccid, int dstcid)
int checkCollision(int cidmask, JGObject obj)
cidmask
- cid mask of objects to consider, 0 means any
int checkBGCollision(JGRectangle r)
r
- bounding box in pixel coordinatesvoid checkBGCollision(int tilecid, int objcid)
java.util.Vector getObjects(java.lang.String prefix, int cidmask, boolean suspended_obj, JGRectangle bbox)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignoresuspended_obj
- also count suspended objectsbbox
- collision bounding box, null means ignorevoid removeObject(JGObject obj)
void removeObjects(java.lang.String prefix, int cidmask)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignorevoid removeObjects(java.lang.String prefix, int cidmask, boolean suspended_obj)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignoresuspended_obj
- also count suspended objectsint countObjects(java.lang.String prefix, int cidmask)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignoreint countObjects(java.lang.String prefix, int cidmask, boolean suspended_obj)
cidmask
- collision id mask, 0 means ignoreprefix
- ID prefix, null means ignoresuspended_obj
- also count suspended objectsvoid setTileCid(int x, int y, int and_mask, int or_mask)
void setTile(int x, int y, java.lang.String tilestr)
int countTiles(int tilecidmask)
int getTileCid(int xidx, int yidx)
java.lang.String getTileStr(int xidx, int yidx)
int getTileCid(JGRectangle tiler)
JGRectangle getTiles(JGRectangle r)
r
- rectangle in pixel coordinates, null is none
boolean getTiles(JGRectangle dest, JGRectangle r)
r
- rectangle in pixel coordinates, null is nonedest
- rectangle to copy tile range into
void drawTile(int xi, int yi, int tileid)
void setTileCid(int x, int y, int value)
void orTileCid(int x, int y, int or_mask)
void andTileCid(int x, int y, int and_mask)
void setTile(JGPoint tileidx, java.lang.String tilename)
void setTiles(int xofs, int yofs, java.lang.String[] tilemap)
void setTilesMulti(int xofs, int yofs, java.lang.String[] tilemap)
"x aa ab abc"
stands for a sequence of four tiles, "x",
"aa", "ab", and "abc".
int getTileCidAtCoord(double x, double y)
int getTileCid(JGPoint center, int xofs, int yofs)
java.lang.String getTileStrAtCoord(double x, double y)
java.lang.String getTileStr(JGPoint center, int xofs, int yofs)
int tileStrToID(java.lang.String tilestr)
tilestr
- tilename, null or empty string -> ID = 0java.lang.String tileIDToStr(int tileid)
tileid
- tile ID, tileid==0 -> tilename = empty stringdouble moduloXPos(double x)
double moduloYPos(double y)
void dbgShowBoundingBox(boolean enabled)
void dbgShowGameState(boolean enabled)
void dbgShowFullStackTrace(boolean enabled)
void dbgShowMessagesInPf(boolean enabled)
A message that is generated in this frame is shown in the foreground colour at the appropriate source. If the source did not generate a message, the last printed message remains visible, and is shown in debug colour 1. If an object prints a message, and then dies, the message will remain for a period of time after the object is gone. These messages are shown in debug colour 2.
void dbgSetMessageExpiry(int ticks)
void dbgSetMessageFont(JGFont font)
void dbgSetDebugColor1(JGColor col)
void dbgSetDebugColor2(JGColor col)
void dbgPrint(java.lang.String msg)
void dbgPrint(java.lang.String source, java.lang.String msg)
source
- may be object ID or "MAIN" for the main program.void dbgShowException(java.lang.String source, java.lang.Throwable e)
source
- may be object ID or "MAIN" for the main program.java.lang.String dbgExceptionToString(java.lang.Throwable e)
void exitEngine(java.lang.String msg)
msg
- an exit message, null means nonevoid initEngineComponent(int width, int height)
width
- canvas widthheight
- canvas heightvoid initEngineApplet()
void initEngine(int width, int height)
width
- real screen width, 0 = use screen sizeheight
- real screen height, 0 = use screen sizevoid setCanvasSettings(int nrtilesx, int nrtilesy, int tilex, int tiley, JGColor fgcolor, JGColor bgcolor, JGFont msgfont)
nrtilesx
- nr of tiles horizontallynrtilesy
- nr of tiles verticallytilex
- width of one tiletiley
- height of one tilefgcolor
- pen/text colour, null for default whitebgcolor
- background colour, null for default blackmsgfont
- font for messages and text drawing, null for defaultvoid setScalingPreferences(double min_aspect_ratio, double max_aspect_ratio, int crop_top, int crop_left, int crop_bottom, int crop_right)
Crop margin can be used if you wish to allow the scaling algorithm to take just a few pixels off your playfield in order to make a wider tile size fit. The tile size is always integer, so even a best-fit scaled tile size may leave an unused border around the playfield, which may be undesirable for small screens. Cropping just a few pixels off the playfield may be just enough to make the tiles 1 pixel larger. Setting a crop to a value greater than zero means you allow the playfield to fall off the canvas for the amount of actual pixels specified, in order to make a larger tile size fit. Default crop margin is 0.
min_aspect_ratio
- minimum width:height ratio allowedmax_aspect_ratio
- maximum width:height ratio allowedcrop_top
- number of pixels to crop at topcrop_left
- number of pixels to crop at left sizecrop_bottom
- number of pixels to crop at bottomcrop_right
- number of pixels to crop at right sizevoid setSmoothing(boolean smooth_magnify)
smooth_magnify
- smooth images when magnifyingvoid requestGameFocus()
boolean isApplet()
boolean isMidlet()
boolean isOpenGL()
boolean isAndroid()
int viewWidth()
int viewHeight()
int viewTilesX()
int viewTilesY()
int viewXOfs()
int viewYOfs()
int pfWidth()
int pfHeight()
int pfTilesX()
int pfTilesY()
boolean pfWrapX()
boolean pfWrapY()
int tileWidth()
int tileHeight()
int displayWidth()
int displayHeight()
void initCanvas()
void initGame()
void start()
void stop()
void startApp()
void pauseApp()
void destroyApp(boolean unconditional)
boolean isRunning()
void wakeUpOnKey(int key)
key
- keycode to wake up on, -1=any key or mouse, 0=nonevoid destroy()
double getFrameRate()
double getFrameSkip()
boolean getVideoSyncedUpdate()
void setViewOffset(int xofs, int yofs, boolean centered)
centered
- center view on (xofs, yofs), topleft otherwisevoid setBGImgOffset(int depth, double xofs, double yofs, boolean centered)
depth
- depth level of image to setcentered
- center view on (xofs, yofs), topleft otherwisevoid setViewZoomRotate(double zoom, double rotate)
Mouse coordinates are inverse projected through the last set zoom/rotate setting, so that a playfield relative pixel drawn at the logical mouse coordinates coincides with the physical position of the mouse pointer. If you don't want this, you can set zoom/rotate to (1,0), read the mouse position, then set zoom/rotate to the desired value.
The zoom/rotate setting used for actual drawing is the last value set at the end of the doFrame phase. Should not be called during the paintFrame phase.
zoom
- zoom factor, 1.0 is normal sizerotate
- angle in radiansvoid setPFSize(int nrtilesx, int nrtilesy)
nrtilesx
- number of tiles, >= viewTilesX()nrtilesy
- number of tiles, >= viewTilesY()void setPFWrap(boolean wrapx, boolean wrapy, int shiftx, int shifty)
void setFrameRate(double fps, double maxframeskip)
fps
- frames per second, useful range 2...80maxframeskip
- max successive frames to skip, useful range 0..10void setVideoSyncedUpdate(boolean value)
void setGameSpeed(double speed)
double getGameSpeed()
void setRenderSettings(int alpha_thresh, JGColor render_bg_col)
alpha_thresh
- bitmask threshold, 0...255, default=128render_bg_col
- bg colour for render, null=use background colourvoid setOffscreenMargin(int xmargin, int ymargin)
int getOffscreenMarginX()
setOffscreenMargin(int,int)
int getOffscreenMarginY()
setOffscreenMargin(int,int)
void setBGColor(JGColor bgcolor)
void setFGColor(JGColor fgcolor)
void setMsgFont(JGFont msgfont)
void setColorsFont(JGColor fgcolor, JGColor bgcolor, JGFont msgfont)
void setTextOutline(int thickness, JGColor colour)
thickness
- 0 = turn off outlinevoid setMouseCursor(int cursor)
void setMouseCursor(java.lang.Object cursor)
void removeAllTimers()
void registerTimer(JGTimer timer)
void setGameState(java.lang.String state)
void addGameState(java.lang.String state)
void removeGameState(java.lang.String state)
void clearGameState()
boolean inGameState(java.lang.String state)
boolean inGameStateNextFrame(java.lang.String state)
void doFrame()
void paintFrame()
double getXScaleFactor()
double getYScaleFactor()
double getMinScaleFactor()
void setColor(JGColor col)
void setFont(JGFont font)
void setStroke(double thickness)
void setBlendMode(int src_func, int dst_func)
src_func
- source multiply factor, 0=one, 1=alpha, -1 = one - alphadst_func
- destination multiply factor, 0=one, 1=alpha, -1 = one - alphadouble getFontHeight(JGFont font)
void drawLine(double x1, double y1, double x2, double y2, double thickness, JGColor color)
void drawLine(double x1, double y1, double x2, double y2)
void drawLine(double x1, double y1, double x2, double y2, boolean pf_relative)
pf_relative
- coordinates are relative to playfield, otherwise viewvoid drawPolygon(double[] x, double[] y, JGColor[] col, int len, boolean filled, boolean pf_relative)
x
- x coordinates of the pointsy
- y coordinates of the pointscol
- colour of each point, null means use default colourlen
- number of pointspf_relative
- coordinates are relative to playfield, otherwise viewvoid drawRect(double x, double y, double width, double height, boolean filled, boolean centered, double thickness, JGColor color)
centered
- indicates (x,y) is center instead of topleft.void drawRect(double x, double y, double width, double height, boolean filled, boolean centered)
centered
- indicates (x,y) is center instead of topleft.void drawRect(double x, double y, double width, double height, boolean filled, boolean centered, boolean pf_relative)
centered
- indicates (x,y) is center instead of topleft.pf_relative
- coordinates are relative to playfield, otherwise viewvoid drawRect(double x, double y, double width, double height, boolean filled, boolean centered, boolean pf_relative, JGColor[] shadecol)
shadecol
- colors topleft,topright,botright,botleft cornersvoid drawRect(double x, double y, double width, double height, boolean filled, boolean centered, boolean pf_relative, JGColor[] shadecol, java.lang.String tileimage)
shadecol
- colors topleft,topright,botright,botleft cornersvoid drawOval(double x, double y, double width, double height, boolean filled, boolean centered, double thickness, JGColor color)
centered
- indicates (x,y) is center instead of topleft.void drawOval(double x, double y, double width, double height, boolean filled, boolean centered)
centered
- indicates (x,y) is center instead of topleft.void drawOval(double x, double y, double width, double height, boolean filled, boolean centered, boolean pf_relative)
centered
- indicates (x,y) is center instead of topleft.pf_relative
- coordinates are relative to playfield, otherwise viewvoid drawImage(double x, double y, java.lang.String imgname)
void drawImage(double x, double y, java.lang.String imgname, boolean pf_relative)
pf_relative
- coordinates are relative to playfield, otherwise viewvoid drawImage(double x, double y, java.lang.String imgname, JGColor blend_col, double alpha, double rot, double scale, boolean pf_relative)
blend_col
- colour to blend with image, null=(alpha,alpha,alpha)alpha
- alpha (blending) value, 0=transparent, 1=opaquerot
- rotation of object in degrees (radians)scale
- scaling of object (1 = normal size).void drawImage(java.lang.String imgname, double x, double y)
void drawImage(java.lang.String imgname, double x, double y, boolean pf_relative)
pf_relative
- coordinates are relative to playfield, otherwise viewvoid drawImage(java.lang.String imgname, double x, double y, boolean pf_relative, JGColor blend_col, double alpha, double rot, double scale)
blend_col
- colour to blend with image, null=(alpha,alpha,alpha)alpha
- alpha (blending) value, 0=transparent, 1=opaquerot
- rotation of object in degrees (radians)scale
- scaling of object (1 = normal size).void drawString(java.lang.String str, double x, double y, int align, JGFont font, JGColor color)
align
- text alignment, -1=left, 0=center, 1=rightvoid drawString(java.lang.String str, double x, double y, int align)
align
- text alignment, -1=left, 0=center, 1=rightvoid drawString(java.lang.String str, double x, double y, int align, boolean pf_relative)
align
- text alignment, -1=left, 0=center, 1=rightpf_relative
- coordinates are relative to playfield, otherwise viewvoid drawImageString(java.lang.String string, double x, double y, int align, java.lang.String imgmap, int char_offset, int spacing)
align
- text alignment, -1=left, 0=center, 1=rightimgmap
- name of image mapchar_offset
- ASCII code of first image of image mapspacing
- number of pixels to skip between lettersvoid drawImageString(java.lang.String string, double x, double y, int align, java.lang.String imgmap, int char_offset, int spacing, boolean pf_relative)
align
- text alignment, -1=left, 0=center, 1=rightimgmap
- name of image mapchar_offset
- ASCII code of first image of image mapspacing
- number of pixels to skip between letterspf_relative
- coordinates are relative to playfield, otherwise viewJGPoint getMousePos()
int getMouseX()
int getMouseY()
boolean getMouseButton(int nr)
nr
- 1=button 1 ... 3 = button 3
void clearMouseButton(int nr)
nr
- 1=button 1 ... 3 = button 3void setMouseButton(int nr)
nr
- 1=button 1 ... 3 = button 3boolean getMouseInside()
boolean getKey(int key)
void clearKey(int key)
void setKey(int key)
int getLastKey()
char getLastKeyChar()
void clearLastKey()
java.lang.String getKeyDesc(int key)
int getKeyCode(java.lang.String keydesc)
boolean hasAccelerometer()
double getAccelX()
double getAccelY()
double getAccelZ()
double[] getAccelVec()
void defineAnimation(java.lang.String id, java.lang.String[] frames, double speed)
id
- the name by which the animation is knownframes
- an array of image names that should be played in sequencespeed
- the sequence speed: the number of animation steps per framevoid defineAnimation(java.lang.String id, java.lang.String[] frames, double speed, boolean pingpong)
id
- the name by which the animation is knownframes
- an array of image names that should be played in sequencespeed
- the sequence speed: the number of animation steps per framepingpong
- true=play the images in forward order, then in reverseAnimation getAnimation(java.lang.String id)
java.lang.String getConfigPath(java.lang.String filename)
int invokeUrl(java.lang.String url, java.lang.String target)
boolean and(int value, int mask)
double random(double min, double max)
double random(double min, double max, double interval)
int random(int min, int max, int interval)
double atan2(double y, double x)
JGPoint getTileIndex(double x, double y)
JGPoint getTileCoord(int tilex, int tiley)
JGPoint getTileCoord(JGPoint tileidx)
double snapToGridX(double x, double gridsnapx)
x
- position to snapgridsnapx
- snap margin, 0.0 means no snapdouble snapToGridY(double y, double gridsnapy)
y
- position to snapgridsnapy
- snap margin, 0.0 means no snapvoid snapToGrid(JGPoint p, int gridsnapx, int gridsnapy)
boolean isXAligned(double x, double margin)
boolean isYAligned(double y, double margin)
double getXAlignOfs(double x)
double getYAlignOfs(double y)
double getXDist(double x1, double x2)
double getYDist(double y1, double y2)
void enableAudio()
void disableAudio()
void defineAudioClip(java.lang.String clipid, java.lang.String filename)
java.lang.String lastPlayedAudio(java.lang.String channel)
void playAudio(java.lang.String clipid)
void playAudio(java.lang.String channel, java.lang.String clipid, boolean loop)
void stopAudio(java.lang.String channel)
void stopAudio()
void storeWriteInt(java.lang.String id, int value)
void storeWriteDouble(java.lang.String id, double value)
void storeWriteString(java.lang.String id, java.lang.String value)
void storeRemove(java.lang.String id)
boolean storeExists(java.lang.String id)
int storeReadInt(java.lang.String id, int undef)
double storeReadDouble(java.lang.String id, double undef)
java.lang.String storeReadString(java.lang.String id, java.lang.String undef)
void optsAddTitle(java.lang.String title)
void optsAddNumber(java.lang.String varname, java.lang.String title, java.lang.String desc, int decimals, double lower, double upper, double step, double initial)
decimals
- number is int if 0void optsAddBoolean(java.lang.String varname, java.lang.String title, java.lang.String desc, boolean initial)
void optsAddEnum(java.lang.String varname, java.lang.String title, java.lang.String desc, java.lang.String[] values, int initial)
void optsAddKey(java.lang.String varname, java.lang.String title, java.lang.String desc, int initial)
void optsAddString(java.lang.String varname, java.lang.String title, java.lang.String desc, int maxlen, boolean isPassword, java.lang.String initial)
void optsClear()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |