Class: Block

Block(game, boundingBox)

Defines a destroyable block

Constructor

new Block(game, boundingBox)

Creates a Block
Parameters:
Name Type Description
game Object The game manager class
boundingBox Object Initial size and position of this Block
Source:

Extends

Members

dimensions

Gets the bounding box dimensions of this Object
Overrides:
Source:

isAlive

Gets whether this Block is still alive
Source:

Methods

AbstractMethod(methodName)

Raises an error if an abstract base class method is called
Parameters:
Name Type Description
methodName string The name of the method that is abstract
Overrides:
Source:

collision(object) → {boolean}

Simple collision test between this GameObject and another
Parameters:
Name Type Description
object Object The GameObject to check for intersection
Overrides:
Source:
Returns:
true/false if colliding
Type
boolean

draw(ctx)

Draws this block on the screen
Parameters:
Name Type Description
ctx Object The Canvas rendering context to draw to.
Overrides:
Source:

intersects(object) → {Object}

Performs a comprehensive collision test that checks where the two objects are overlapping and indicates the closest point to move them out of collision.
Parameters:
Name Type Description
object Object The object to check for intersection
Overrides:
Source:
Returns:
a dictionary with side: axis of intersection and pos: closest point of non-intersection
Type
Object