Class: Entity

Splat. Entity

new Entity(x, y, width, height)

The base in-game object, it supports a location and velocity. Entities are boxes, consisting of an x,y coordinate along with a width and height. Entities have basic collision detection and resolution.
Parameters:
Name Type Description
x number The top-left x coordinate
y number The top-left y coordinate
width number The width on the x-axis
height number The height on the y-axis
Source:

Members

height :number

Height of the Entity, extending downward from Splat.Entity#y.
Type:
  • number
Source:

(readonly) lastX :number

The value of Splat.Entity#x in the previous frame.
Type:
  • number
Source:

(readonly) lastY :number

The value of Splat.Entity#y in the previous frame.
Type:
  • number
Source:

vx :number

Velocity along the x-axis in pixels/millisecond.
Type:
  • number
Source:

vy :number

Velocity along the y-axis in pixels/millisecond.
Type:
  • number
Source:

width :number

Width of the Entity, extending to the right of Splat.Entity#x.
Type:
  • number
Source:

x :number

Leftmost position along the x-axis.
Type:
  • number
Source:

y :number

Topmost position along the y-axis.
Type:
  • number
Source:

Methods

collides(other) → {boolean}

Test if this Entity is currently colliding with another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for collision with
Source:
Returns:
Type
boolean

didOverlapHoriz(other) → {boolean}

Test if this Entity horizontally overlapped another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Source:
Returns:
Type
boolean

didOverlapVert(other) → {boolean}

Test if this Entity vertically overlapped another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Source:
Returns:
Type
boolean

getCollisions(entities) → {Array}

Return a list of all Entities that collide with this Entity.
Parameters:
Name Type Description
entities Array A list of Entities to check for collisions.
Source:
Returns:
A list of entities that collide with this Entity.
Type
Array

move(elapsedMillis)

Simulate movement since the previous frame, changing Splat.Entity#x and Splat.Entity#y as necessary.
Parameters:
Name Type Description
elapsedMillis number The number of milliseconds since the previous frame.
Source:

moved() → {boolean}

Test if this Entity has changed position since the previous frame.
Source:
Returns:
Type
boolean

overlapsHoriz(other) → {boolean}

Test if this Entity horizontally overlaps another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Source:
Returns:
Type
boolean

overlapsVert(other) → {boolean}

Test if this Entity vertically overlaps another.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for overlap with
Source:
Returns:
Type
boolean

resolveBottomCollisionWith(other)

Adjust the Entity's position so its bottom edge does not penetrate the other Entity's top edge. Splat.Entity#vy is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Source:

resolveCollisionWith(other)

Adjust the Entity's position so it does not penetrate the other Entity. Splat.Entity#vx will be zeroed if Splat.Entity#x was adjusted, and Splat.Entity#vy will be zeroed if Splat.Entity#y was adjusted.
Parameters:
Name Type Description
other Splat.Entity
Source:

resolveLeftCollisionWith(other)

Adjust the Entity's position so its left edge does not penetrate the other Entity's right edge. Splat.Entity#vx is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Source:

resolveRightCollisionWith(other)

Adjust the Entity's position so its right edge does not penetrate the other Entity's left edge. Splat.Entity#vx is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Source:

resolveTopCollisionWith(other)

Adjust the Entity's position so its top edge does not penetrate the other Entity's bottom edge. Splat.Entity#vy is also zeroed.
Parameters:
Name Type Description
other Splat.Entity
Source:

solveCollisions(entities) → {Array}

Detect and resolve collisions between this Entity and a list of other Entities
Parameters:
Name Type Description
entities Array A list of Entities to solve against.
Source:
Returns:
A list of entities that were involved in collisions.
Type
Array

wasAbove(other) → {boolean}

Test if this Entity was above another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for above-ness with
Source:
Returns:
Type
boolean

wasBelow(other) → {boolean}

Test if this Entity was below another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for below-ness with
Source:
Returns:
Type
boolean

wasLeft(other) → {boolean}

Test if this Entity was to the left of another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for left-ness with
Source:
Returns:
Type
boolean

wasRight(other) → {boolean}

Test if this Entity was to the right of another in the previous frame.
Parameters:
Name Type Description
other Splat.Entity The Entity to test for right-ness with
Source:
Returns:
Type
boolean