Create a namespace to store all the physics engine core functionality
Type: ({} | {})
Component to store objects and main game loop
Type: {}
Component to store collision detection and resolving
Type: {}
Component to store a reference to a player ship
Type: PlayerShip
Engine Loop
Collision detection
Type: function
Resolve collision using the Impulse Method
(any)
one of the colliding objects
(any)
one od the colliding objects
(CollisionInfo)
collision info calculated while collision detection
Collision position
Type: Vector
Tangent to a collision normal
Type: Vector
Reduces overlaps between objects by the predefined constant correctionRate
Type: Vector
Add drag to objects if they are in a drag area
Change Rigid Shape velocity due to drag
Component to store canvas data
Type: {mHeight: any, mWidth: any, mCanvas: HTMLElement, mContext: any}
Canvas boundaries
Class that represents a bullet
A class that represents a bullet source
A class that represent a fuel tank
Function to draw canvas background
Create bunkers object on level
Create fuel object on level
Create drag areas object on level
Set level initial scene
Set terrain on level
Terrain object, stores all terrain elements
Button to start game
Draw a button to start game
Check if user clicked a button
(any)
click event
Set event listener and draw a button
Get user's mouse coordinates
(any)
mouse event
{x: number, y: number}
:
mouse coordinates
Check if mouse is inside a button
(any)
mouse position
(any)
button
boolean
:
Start game, clear previous data
Class that represents player ship
Object to store game stats
Function to display stats on canvas
Function to update stats in each loop run
(any)
player score
(any)
player lives left
(any)
player fuel
Handle keyboard inputs
(any)
keyboard event
boolean
:
Class that represents collision info
Class that represents a drag area
Class that represents a sine wave used in DragArea animation
Function to execute code after a given time
(any)
waiting time
Promise<unknown>
:
A class that represents a vector using Cartesian coordinates
Method to multiply (scale) a vector by a scalar n
(any)
scalar by which the vector is multiplied
any
:
product of vector scaling
Method to normalize the vector that called it, i.e. multiply the vector by a factor so that its magnitude is equal to 1
any
:
normalized vector
Draw the vector
(any)
vector color
Constructor of Circle class
(number)
Circle mass
(Vector)
Circle center location
(number)
Circle radius
(number
= 0
)
Circle angle in radians
(number
= 0
)
Circle friction
(number
= 0
)
Circle restitution (bounciness) (how much energy is preserved after collision)
(boolean
= true
)
consider Circle when applying gravity
(string
= ""
)
additional info
Rotate circle
(number)
rotation angle in radians
Display hit box
Set and update inertia
Check if collision occurred, call specified methods to handle collision
(any)
other shape in the collision event
(any)
collision info
boolean
:
did the collision occur
Handle collision between circles
(any)
first circle
(any)
second circle
(any)
collision info
(boolean | CollisionInfo)
:
Type: Vector
Constructor of a Rectangle object
(number)
Mass of a Rectangle object
(Vector)
Mass center of a Rectangle object
(number)
Width of a Rectangle object
(number)
Height of a Rectangle object
(number
= 0
)
Angle in radians of a Rectangle object axis to global (canvas) x-axis
(number
= 0
)
Rectangle friction
(number
= 0
)
Rectangle restitution (bounciness) (how much energy is preserved after collision)
(boolean
= true
)
consider the Rectangle when applying gravity
(string
= ""
)
additional info
Array to store vertex positions of the rectangle
Array to store the face normal vectors
Compute Rectangle vertices
Compute face normal vectors
Rotate Rectangle
(number)
Angle in radians
Set and update inertia
(any)
(any)
boolean
:
Compute a support point based on dir (find a support point for any face normal)
(Vector)
Negated face normal direction
(Vector)
A position on the given edge (e.g. a vertex)
{supportPoint: Vector, supportPointDist: number}
:
Find the axis of the least penetration based on the support point with the least support point distant
(Rectangle)
other Rectangle with which collision occurs
(any)
collision info
boolean
:
hasSupport
Compute the axis of lest penetration and choose smaller of the two results
(Rectangle)
Rectangle that called the method
(Rectangle)
Rectangle with which collision occurs
(CollisionInfo)
collision info
boolean
:
Detect collision according to the relative position of the circle's center with respect to the rectangle
(Circle)
collided Circle
(CollisionInfo)
collision info
Type: Vector
Type: Vector
Type: CollisionInfo
Type: CollisionInfo
Type: CollisionInfo
Type: CollisionInfo
Type: Vector
Abstract class that represents a rigid body
Angular velocity is stored as a scalar representing the z-component magnitude of the vector
Type: number
Update RigidBody object with its velocity, move and rotate accordingly
Support changing of the mass during runtime
(any)
mass change
Detect collision
((Circle | Rectangle | Triangle))
collided Circle
(CollisionInfo)
collision info
Symplectic Euler Integration
Constructor of a Triangle object
(number)
Mass of a Triangle object
(Vector)
Mass center of a Triangle object
(number)
Width of a Triangle object
(number)
Height of a Triangle object
(number
= 0
)
Angle in radians of a Triangle object axis to global (canvas) x-axis
(number
= 0
)
Triangle friction
(number
= 0
)
Triangle restitution (bounciness) (how much energy is preserved after collision)
(boolean
= true
)
consider the Triangle when applying gravity
(string
= ""
)
additional info
Array to store vertex positions of the triangle
Array to store the face normal vectors
Compute Rectangle vertices
Compute face normal vectors
Rotate Rectangle
(number)
Angle in radians
Set and update inertia
Check if collision occurred, call specified methods to handle collision
(any)
other shape in the collision event
(any)
collision info
boolean
:
did the collision occur
Compute a support point based on dir (find a support point for any face normal)
(Vector)
Negated face normal direction
(Vector)
A position on the given edge (e.g. a vertex)
{supportPoint: Vector, supportPointDist: number}
:
Find the axis of the least penetration based on the support point with the least support point distance
((Rectangle | Triangle))
other Rectangle or Triangle with which collision occurs
(any)
collision info
boolean
:
hasSupport
Compute the axis of lest penetration and choose smaller of the two results
(Triangle)
Triangle that called the method
((Triangle | Rectangle))
Triangle or Rectangle with which collision occurs
(CollisionInfo)
collision info
boolean
:
Detect collision according to the relative position of the circle's center with respect to the triangle
(any)
collided Circle
(any)
collision info
boolean
:
Type: Vector