PhysicsComponent#

new PhysicsComponent(vel, angularVel, friction, mass, bounce)#

Create a new physics component.
Parameters:
NameTypeDescription
velnumber | Vec2Initial velocity
angularVelnumberInitial angular velocity
frictionnumberFriction to be applied
massnumberMass of object
bouncenumberBounce percentage on collision

Extends#

Methods#

destructor()#

Handle the deletion of the component.

doMove(elapsed)#

Perform movement and check collisions as necessary.
Parameters:
NameTypeDescription
elapsednumberTime since last update cycle in seconds

draw(ctx)#

Draw the component.
Parameters:
NameTypeDescription
ctxCanvasRenderingContext2DCanvas context to draw on

drawDebug(ctx)#

Draw debugging info for the component.
Parameters:
NameTypeDescription
ctxCanvasRenderingContext2DCanvas context to draw on

init()#

Initialize the component.

update(elapsed)#

Update the component.
Parameters:
NameTypeDescription
elapsednumberTime since last update cycle in seconds