AISceneryThrower

AISceneryThrower

A TravelingSceneryThrower for platformers that is supposed to be computer controlled. General use would be to construct it call setTarget, and then call .thinkAboutWhatToDo during a loop.


Constructor

new AISceneryThrower(x, y, width, height, map, caopt, dontCloneMapopt, dtopt, tWidthopt, tHeightopt, mropt, mcopt)

Parameters:
Name Type Attributes Default Description
x Number

x position of the AISceneryThrower

y Number

y position of the AISceneryThrower

width Number

width of the AISceneryThrower

height Number

height of the AISceneryThrower

map Array

collision map Array

ca CanvasAnimation <optional>
null

Optional CanvasAnimation

dontCloneMap Boolean <optional>
false

When true map will not be cloned, default is false, map is cloned by default.

dt Number <optional>
.666666666667

Delta time, default is TimeKeeper._sae, change TimeKeeper._sae to effect all Travelers you use.

tWidth Number <optional>

Tile width default is same as width

tHeight Number <optional>

Tile height default is same as height

mr Number <optional>

amount of rows in map

mc Number <optional>

amount of columns in map

Members

_target

The MoverSkeleton target to try to hit with scenery.

afterAttackDelay :Number

delay after an attack before another attack used during thinkAboutWhatToDo

Type:
  • Number

backUp :Number

back up time, used by thinkAboutWhatToDo

Type:
  • Number

pickUpMethodToUse :Number

Determines the pick up method to use when picking up SceneryObjects 1 for pickUpAndStore 0 for pickUp Those methods are inherited from TravelingSceneryThrower

Type:
  • Number

watchingThrow :Number

time of watching throw used during thinkAboutWhatToDo

Type:
  • Number

Methods

jump(direc)

Causes the AISceneryThrower to move up. Used by thinkAboutWhatToDo.

Parameters:
Name Type Description
direc Number

setTarget(t)

Sets _target

Parameters:
Name Type Description
t MoverSkeleton

A MoverSkeleton or Object with x y width height.

smarts(level, twopt, thopt) → {Boolean}

Determines the distance that the AISceneryThrower throws from and its throw strength. This method is called by walkJumpOrAttack which is called by thinkAboutWhatToDo.

Parameters:
Name Type Attributes Default Description
level Number

Level of smarts, 1 2 or 3.

tw Number <optional>
16

Tile width, default is 16

th Number <optional>
16

Tile height, default is 16

Returns:

Returns true if facing and close to the _target based on the smarts level.

Type
Boolean

thinkAboutWhatToDo(sceneryArray, sceneryMap, sceneryCheck, sceneryRemoval, twopt, thopt, smartnessopt, tileCheck)

The main method of the class, causes the AISceneryThrower to first look for SceneryObjects and then pick one up and then try to hit the _target with it.

Parameters:
Name Type Attributes Default Description
sceneryArray Array

The array that holds the SceneryObjects

sceneryMap Array

The map that each SceneryObject is using.

sceneryCheck function

A method that dermines if a tile value is a SceneryObejct, it should take a tile value and return a Boolean.

sceneryRemoval function

A method that removes TileData from being displayed/drawn. It should take a TileData and clears the display of the TileData.

tw Number <optional>
16

Tile width, default is 16

th Number <optional>
16

Tile height default is 16

smartness Number <optional>
1

1 2 or 3, determines how far away the AISceneryThrower will throw from and its throw strength. Default is 1.

tileCheck function

A method that should determine if a tile value is solid/passible or not.

walk(direc)

Causes the AISceneryThrower to move left or right. Used by thinkAboutWhatToDo.

Parameters:
Name Type Description
direc Number

1 for left, 0 for right.

walkJumpOrAttack(direc, tw, th, sceneryArray, smartness, A)

Causes the AISceneryThrower to move or jump or throw a SceneryObejct its holding. This method is used by thinkAboutWhatToDo.

Parameters:
Name Type Description
direc Number

1 for left, 0 for right.

tw Number

Tile width

th Number

Tile height

sceneryArray Array

The Array holding the SceneryObejcts.

smartness Number

1 2 or 3, determines how far away the AISceneryThrower will throw from and its throw strength. Default is 1.

A function

method that should determine if a tile value is solid/passible or not.

walkOrJump(direc, twopt, thopt, closeSceneryX, tileCheck)

Moves the AISceneryThrower to walk or jump if one tile is in the way. This method is used by thinkAboutWhatToDo.

Parameters:
Name Type Attributes Default Description
direc Number

1 for left, 0 for right.

tw Number <optional>
16

Tile width, default is 16.

th Number <optional>
16

Tile height, default is 16

closeSceneryX Number

The x position of the closest SceneryObejct, this is calculated by thinkAboutWhatToDo

tileCheck function

A method that determines if a tile value is solid/passible or not.