|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjgame.JGObject
examples.StdMazePlayer
A standard object that allows the player to move in 4 directions around a maze. Typical application: pac-man. This class only defines the move() method; hit() and hit_bg() are not used. Subclass it to customize. To customize move(), call super.move() somewhere inside your move method. You are not adviced to touch x, y, xdir, ydir, xspeed, yspeed. It is assumed the object is 1x1 tile in size, and the tileBBox is set to this.
The public fields are the configuration fields which can be changed at will during the object's lifetime.
You can make movement stop by setting the stop_moving flag. The player will move on to the next aligned position, then halt until the flag is cleared. In some games, the player should freeze when the movement keys are used for firing or special actions.
Field Summary | |
int |
block_mask
cid mask of tiles that block |
boolean |
continuous_anim
don't stop animating when player stops moving |
java.lang.String |
gfx_prefix
null indicates non-directional graphic |
int |
key_down
movement key |
int |
key_left
movement key |
int |
key_right
movement key |
int |
key_up
movement key |
double |
speed
object's speed, overrides xspeed, yspeed. |
boolean |
stop_moving
set to true to disable movement (for example, for firing) |
Fields inherited from class jgame.JGObject |
colid, eng, expire_never, expire_off_pf, expire_off_view, expiry, resume_in_view, suspend_off_view, suspend_off_view_expire_off_pf, x, xdir, xspeed, y, ydir, yspeed |
Constructor Summary | |
StdMazePlayer(java.lang.String name,
double x,
double y,
int cid,
java.lang.String graphic,
boolean is_directional,
boolean continuous_anim,
int block_mask,
double speed,
int key_up,
int key_down,
int key_left,
int key_right)
When initialised, the object will snap to grid to the nearest free position. |
Method Summary | |
void |
move()
Moves the object around. |
Methods inherited from class jgame.JGObject |
and, checkBGCollision, checkBGCollision, clearAnim, clearBBox, clearTileBBox, dbgPrint, finalize, getAnimId, getBBox, getCenterTile, getCenterTiles, getGraphic, getImageBBox, getLastBBox, getLastCenterTiles, getLastTileBBox, getLastTiles, getLastX, getLastY, getName, getTileBBox, getTiles, getTopLeftTile, hit_bg, hit_bg, hit_bg, hit, isAligned, isAlive, isBottomAligned, isInView, isLeftAligned, isOnPF, isOnScreen, isRightAligned, isSuspended, isTopAligned, isXAligned, isXAligned, isYAligned, isYAligned, paint, remove, resetAnim, resetAnim, resume, setAnim, setAnimPingpong, setAnimSpeed, setBBox, setDir, setDirSpeed, setDirSpeed, setGraphic, setImage, setPos, setResumeMode, setSpeed, setSpeed, setSpeedAbs, setTileBBox, snapBBoxToGrid, snapToGrid, snapToGrid, startAnim, stopAnim, suspend |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public java.lang.String gfx_prefix
public boolean continuous_anim
public int block_mask
public double speed
public int key_up
public int key_down
public int key_left
public int key_right
public boolean stop_moving
Constructor Detail |
public StdMazePlayer(java.lang.String name, double x, double y, int cid, java.lang.String graphic, boolean is_directional, boolean continuous_anim, int block_mask, double speed, int key_up, int key_down, int key_left, int key_right)
x
- position in pixelsy
- position in pixelsgraphic
- prefix of graphicis_directional
- true = add direction suffix to graphiccontinuous_anim
- don't stop animating when player stops movingblock_mask
- cid mask of tiles that blockMethod Detail |
public void move()
move
in class JGObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |