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

## examples
Class StdMazePlayer

    java.lang.Object
      jgame.JGObject
          examples.StdMazePlayer

    public class StdMazePlayer

extends JGObject

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, 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
`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, checkCollision, clearAnim, clearBBox, clearTileBBox, dbgPrint, destroy, frameFinished, getAnimId, getBBox, getBBox, getCenterTile, getCenterTiles, getGraphic, getImageBBox, getImageBBoxConst, getImageName, getLastX, getLastY, getName, getTileBBox, getTileBBox, getTiles, getTopLeftTile, hit_bg, hit_bg, hit_bg, hit, isAligned, isAlive, isBottomAligned, isInView, isLeftAligned, isOnPF, isOnScreen, isRightAligned, isSuspended, isTopAligned, isXAligned, isXAligned, isYAligned, isYAligned, moduloPos, paint, remove, removeDone, resetAnim, resetAnim, resume, setAnim, setAnimPingpong, setAnimSpeed, setBBox, setDir, setDirSpeed, setDirSpeed, setEngine, setGraphic, setImage, setPos, setResumeMode, setSpeed, setSpeed, setSpeedAbs, setTileBBox, snapBBoxToGrid, snapToGrid, snapToGrid, startAnim, stopAnim, suspend, updateAnimation, updateEngineSettings`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### gfx_prefix

    public java.lang.String gfx_prefix

  null indicates non-directional graphic

### continuous_anim

    public boolean continuous_anim

  don't stop animating when player stops moving

### block_mask

    public int block_mask

  cid mask of tiles that block

### speed

    public double speed

  object's speed, overrides xspeed, yspeed.

### key_up

    public int key_up

  movement key

### key_down

    public int key_down

  movement key

### key_left

    public int key_left

  movement key

### key_right

    public int key_right

  movement key

### stop_moving

    public boolean stop_moving

  set to true to disable movement (for example, for firing)

Constructor Detail

### StdMazePlayer

    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)

  When initialised, the object will snap to grid to the nearest free position. The object's graphic can be made directional by setting is_directional. This will add the suffix "u", "d", "l", or "r" to the graphic string to indicate the direction of movement.

  Parameters:
    `x` - position in pixels
    `y` - position in pixels
    `graphic` - prefix of graphic
    `is_directional` - true = add direction suffix to graphic
    `continuous_anim` - don't stop animating when player stops moving
    `block_mask` - cid mask of tiles that block

Method Detail

### move

    public void move()

  Moves the object around. If you override this, be sure to call super.move() and don't touch x, y, xspeed, yspeed, xdir, ydir.

  Overrides:
    `move` in class `JGObject`

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