new PhysicsComponent(vel, angularVel, friction, mass, bounce)
Create a new physics component.
Parameters:
Name | Type | Description |
---|---|---|
vel | number | | Initial velocity |
angularVel | number | Initial angular velocity |
friction | number | Friction to be applied |
mass | number | Mass of object |
bounce | number | Bounce percentage on collision |
Extends
Methods
destructor()
Handle the deletion of the component.
- Overrides
doMove(elapsed)
Perform movement and check collisions as necessary.
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update cycle in seconds |
draw(ctx)
Draw the component.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
drawDebug(ctx)
Draw debugging info for the component.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
init()
Initialize the component.
- Overrides
update(elapsed)
Update the component.
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update cycle in seconds |
- Overrides