2022-11-20 15:50:14 -06:00
|
|
|
# Yugine Scripting
|
|
|
|
|
2023-05-29 10:47:30 -05:00
|
|
|
Scripting is done with JS.
|
|
|
|
|
|
|
|
Load up objects with functions that are called back at specific times.
|
|
|
|
|
|
|
|
Levels and objects have certain functions you can use that will be
|
|
|
|
called at particular times during the course of the game running.
|
|
|
|
|
|
|
|
setup
|
|
|
|
Called once, when the object is created.
|
|
|
|
|
|
|
|
start
|
|
|
|
Called once when the gameplay is simulating.
|
|
|
|
|
|
|
|
update(dt)
|
|
|
|
Called once per frame, while the game is simulating
|
|
|
|
|
|
|
|
physupdate(dt)
|
|
|
|
Called once per physics step
|
|
|
|
|
|
|
|
stop
|
|
|
|
Called when the object is destroyed, either by being killed or otherwise.
|
|
|
|
|
|
|
|
.Collider functions
|
|
|
|
Colliders get special functions to help with collision handling.
|
|
|
|
|
|
|
|
collide(hit)
|
|
|
|
Called when an object collides with the object this function is on.
|
|
|
|
|
|
|
|
"hit" object
|
|
|
|
normal - A vector in the direction the hit happened
|
|
|
|
hit - Object ID of colliding object
|
|
|
|
sensor - True if the colliding object is a sensor
|
|
|
|
velocity - A vector of the velocity of the collision
|
|
|
|
|
|
|
|
.Draw functions
|
|
|
|
draw()
|
|
|
|
Called during lower rendering
|
|
|
|
|
|
|
|
gui()
|
|
|
|
Called for screen space over the top rendering
|
|
|
|
|
|
|
|
debug()
|
|
|
|
Called during a debug phase; Will not be called when debug draw is off
|
|
|
|
|
2023-06-28 11:35:41 -05:00
|
|
|
## Important objects
|
|
|
|
There are a number of possible ways to create a script in the context of the game world.
|