Methods
# applyForce(force)
Apply force to particle
Parameters:
Name | Type | Description |
---|---|---|
force |
Vector2D
|
Force vector |
# applyGravity(other, G)
Apply gravitational force from another particle
Parameters:
Name | Type | Default | Description |
---|---|---|---|
other |
PhysicsParticle
|
Other particle |
|
G |
number
|
0.1 | Gravitational constant |
# bounceOffBoundaries(width, height)
Bounce off boundaries
Parameters:
Name | Type | Description |
---|---|---|
width |
number
|
Boundary width |
height |
number
|
Boundary height |
# collidesWith(other) → {boolean}
Check collision with another particle
Parameters:
Name | Type | Description |
---|---|---|
other |
PhysicsParticle
|
Other particle |
Collision detected
boolean
# resolveCollision(other)
Resolve collision with another particle
Parameters:
Name | Type | Description |
---|---|---|
other |
PhysicsParticle
|
Other particle |
# update(deltaTime)
Update particle physics
Parameters:
Name | Type | Description |
---|---|---|
deltaTime |
number
|
Time step |
# wrapAroundBoundaries(width, height)
Wrap around boundaries
Parameters:
Name | Type | Description |
---|---|---|
width |
number
|
Boundary width |
height |
number
|
Boundary height |