|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjgame.JGObject
examples.StdDungeonPlayer
public class StdDungeonPlayer
A standard object that allows the player to move in 8 directions around a tile-based dungeon, which may be maze-like or contain open spaces. Typical application: gauntlet, and a variety of others. The player moves in 8 directions along tile-aligned positions. It can be made to occupy a space on the tile map, blocking other objects. The occupation is automatically removed if the object is removed. 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 stop when the movement keys are used for firing or doing actions.
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. While in general you shouldn't touch the object's position, direction, or speed in order to ensure correct behaviour, you can set any of the configuration variables in the move() method or somewhere else.
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 keys. |
int |
key_left
Movement keys. |
int |
key_right
Movement keys. |
int |
key_up
Movement keys. |
int |
occupy_mask
cid mask that object should use to indicate occupation |
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, gamespeed, is_suspended, pfheight, pfwidth, pfwrapx, pfwrapy, resume_in_view, suspend_off_view, suspend_off_view_expire_off_pf, tileheight, tilewidth, viewheight, viewwidth, viewxofs, viewyofs, x, xdir, xspeed, y, ydir, yspeed |
Constructor Summary | |
---|---|
StdDungeonPlayer(java.lang.String name,
double x,
double y,
int cid,
java.lang.String graphic,
boolean is_directional,
boolean continuous_anim,
int block_mask,
int occupy_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 |
destroy()
Removes object and object's occupation. |
void |
move()
Moves the object around, and ensures it occupies space. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, 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 int occupy_mask
public int key_up
public int key_down
public int key_left
public int key_right
public boolean stop_moving
Constructor Detail |
---|
public StdDungeonPlayer(java.lang.String name, double x, double y, int cid, java.lang.String graphic, boolean is_directional, boolean continuous_anim, int block_mask, int occupy_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 blockoccupy_mask
- cid mask that object should use to indicate occupationMethod Detail |
---|
public void move()
move
in class JGObject
public void destroy()
destroy
in class JGObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |