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 StdMazeMonster

    java.lang.Object
      jgame.JGObject
          examples.StdMazeMonster

    public class StdMazeMonster

extends JGObject

A standard object that moves 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(), simply call super.move() somewhere inside your move method. Note that this class's move() works by determining the appropriate xdir and ydir. You can do some limited operations on xdir and ydir before calling super.move(). In particular, reversing direction can be done without problems. 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.

The object homes in on the specified home_in object, or can be made to avoid it. The object can be made to move randomly instead of homing in/ avoiding, with a specified probability between 0 and 1. Not setting home_in will make the object move randomly.

The object tries to keep moving forward, and never make u-turns (like pac-man ghosts) to help get it around cul de sacs. There is no AI for finding complex routes through the maze.

Field Summary
`boolean` | `avoid` true = avoid home_in position
`int` | `block_mask` cid mask of tiles that block
`java.lang.String` | `gfx_prefix` null indicates non-directional graphic
`JGObject` | `home_in` object to home in on, null=none (random movement)
`double` | `random_proportion` chance that object moves randomly
`double` | `speed` object's speed, overrides xspeed, yspeed.

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
`StdMazeMonster(java.lang.String name, boolean unique_id, double x, double y, int cid, java.lang.String graphic, boolean is_directional, int block_mask, int xdir, int ydir, double speed, JGObject home_in, boolean avoid, double random_proportion)` When initialised, the object will snap to grid to the nearest free position, then it will start moving in the direction specified by xdir, ydir.

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

### block_mask

    public int block_mask

  cid mask of tiles that block

### speed

    public double speed

  object's speed, overrides xspeed, yspeed.

### home_in

    public JGObject home_in

  object to home in on, null=none (random movement)

### avoid

    public boolean avoid

  true = avoid home_in position

### random_proportion

    public double random_proportion

  chance that object moves randomly

Constructor Detail

### StdMazeMonster

    public StdMazeMonster(java.lang.String name,
                          boolean unique_id,
                          double x,
                          double y,
                          int cid,
                          java.lang.String graphic,
                          boolean is_directional,
                          int block_mask,
                          int xdir,
                          int ydir,
                          double speed,
                          JGObject home_in,
                          boolean avoid,
                          double random_proportion)

  When initialised, the object will snap to grid to the nearest free position, then it will start moving in the direction specified by xdir, ydir. The object's graphic can be made directional by setting is_directional. This will add the suffix "l", "r", "u", or "d" 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` - add direction suffix to graphic
    `home_in` - object to home in on, null=none (random movement)
    `avoid` - true = avoid home_in position
    `random_proportion` - chance that object moves randomly
    `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. Don't touch xdir, ydir except by possibly reversing them.

  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