¶
luxe
API (2025.1.2
)¶
luxe: game
module¶
Frame¶
import "luxe: game" for Frame
Access to the frame and game loop. At the moment, the loop contains fixed sections,
begin
->init
->sim
->visual
->debug
->end
.Functions can be hooked into sections of the frame using
before
,after
oron
ordering.Note: This API is a work in progress.
- begin
- init
- sim
- visual
- debug
- end
- queue(fn:
Fn
) - next(fn:
Fn
) - end(fn:
Fn
) - schedule(time:
Num
, fn:Fn
) - schedule(time:
Num
, count:Num
, fn:Fn
) - unschedule(handle:
Handle
) - off(handle:
Handle
) - once(section:
String
, priority:Num
, fn:Fn
) - on(section:
String
, priority:Num
, fn:Fn
) - before(section:
String
, priority:Num
, fn:Fn
) - after(section:
String
, priority:Num
, fn:Fn
) - on(section:
String
, fn:Fn
) - once(section:
String
, fn:Fn
) - before(section:
String
, fn:Fn
) - after(section:
String
, fn:Fn
) - skip(count_frames:
Num
, fn:Fn
) - mark(id:
String
, display:String
) - get_marks(frame_index:
Num
) - index
- delta
String
An enum value for the
begin
section in the loop. The `begin section is the start of the frame from the game's perspective.Frame.on(Frame.begin) {|delta| ... }
String
An enum value for the
init
section in the loop. Theinit
section is used for initialization tasks that happen before updates, like when a new entity is created, it can be added to a queue and processed in init to set some default values before it arrives insim
orvisual
.Frame.on(Frame.init) {|delta| ... }
String
An enum value for the
sim
section in the loop. Thesim
section is for simulation, also known asupdate
. In this section you would update game logic and modify things that thevisual
section would reference.Frame.on(Frame.sim) {|delta| ... }
String
An enum value for the
visual
section in the loop. Thevisual
section is for rendering, also known asrender
. Updating visual state from the sim states happens here.Frame.on(Frame.visual) {|delta| ... }
String
An enum value for the
debug
section in the loop. Thedebug
part of the loop can perform debug related tasks before the end of the frame and rendering is submitted.Frame.on(Frame.debug) {|delta| ... }
String
An enum value for the
end
section in the loop. Theend
of the loop can perform tasks after rendering and simulation.Frame.on(Frame.end) {|delta| ... }
Fn
)
¶None
Once off. Queue a function to be called after the current section has completed fully. That is, if we were inside of
sim
and we queued a function, it would happen afterbefore
on
andafter
.This is used for systems that fire callbacks, you normally don't want to fire callbacks during processing, so you can queue them to happen "as soon as possible" but in a well defined place and time.
Frame.queue { Log.print("happens at the end of the current section") } //fake example: collision callbacks for(entity in collidable) { if(collides(entity)) { var fn = callbacks[entity] Frame.queue { fn.call() } } }
Fn
)
¶None
Once off. Queue a function to be called at the beginning of the next frame, before any sections.
Frame.next { Log.print("next frame!") } //common example, destroying something when it might //not be safe to. Instead, just destroy it later for(thing in list) { Frame.next { Thing.destroy(thing) } }
Fn
)
¶None
Once off. Queue a function to be called at the end of the current frame, after all sections.
Frame.end { Log.print("end frame!") }
Num
, fn: Fn
)
¶Handle
Schedule a function to be called in future. The
time
value is in seconds, and is not affected by any time scaling. The function is only called once. To repeat, see the otherschedule
method.
Num
, count: Num
, fn: Fn
)
¶Handle
Schedule a function to be called in future. The
time
value is in seconds, and is not affected by any time scaling. Ifcount
is 0, the function will be called repeatedly untilunschedule
is called.
Handle
)
¶None
Unschedule a function scheduled previously, using the handle returned from
schedule
.
Handle
)
¶Bool
Disconnect a function using the handle returned from one of the recurring functions. This will remove the function from the loop and it will no longer be called.
Returns true if the function was valid and removed.
var tick = Frame.on(Frame.sim) {|delta| Log.print("delta:%(delta)") } //... Frame.off(tick)
String
, priority: Num
, fn: Fn
)
¶Handle
Once off. Queues a function to the specified section, with a given priority which will be executed during the section. Priority is based on "highest priority first". So priority 1 executes before 0.
Returns a handle that can be used to remove the function via
off
.Frame.once(Frame.sim, 3) {|delta| Log.print("prints first") } Frame.once(Frame.sim, 1) {|delta| Log.print("prints second") }
String
, priority: Num
, fn: Fn
)
¶Handle
Connect a function to the specified section, with a given priority which will be executed during the section. Priority is based on "highest priority first". So priority 1 executes before 0.
Returns a handle that can be used to remove the function via
off
.Frame.on(Frame.sim, 3) {|delta| Log.print("prints first") } Frame.on(Frame.sim, 1) {|delta| Log.print("prints second") }
String
, priority: Num
, fn: Fn
)
¶Handle
Connect a function to the specified section, with a given priority which will be executed before the section. Priority is based on "highest priority first". So priority 1 executes before 0.
Returns a handle that can be used to remove the function via
off
.Frame.before(Frame.sim, 0) {|delta| Log.print("prints second") } Frame.before(Frame.sim, 1) {|delta| Log.print("prints first") }
String
, priority: Num
, fn: Fn
)
¶Handle
Connect a function to the specified section, with a given priority which will be executed after the section. Priority is based on "highest priority first". So priority 1 executes before 0.
Returns a handle that can be used to remove the function via
off
.Frame.after(Frame.sim, 2) {|delta| Log.print("prints first") } Frame.after(Frame.sim, 1) {|delta| Log.print("prints second") }
String
, fn: Fn
)
¶Handle
Connect a function to the specified section (with priority 0) which will be executed during the section.
Returns a handle that can be used to remove the function via
off
.Frame.on(Frame.sim) {|delta| Log.print("delta:%(delta)") }
String
, fn: Fn
)
¶Handle
Once off. Queue a function to the specified section (with priority 0) which will be executed during the section. Returns a handle that can be used to remove the function via
off
.Frame.once(Frame.sim) { Log.print("happens during 'sim'") }
String
, fn: Fn
)
¶Handle
Connect a function to the specified section (with priority 0) which will be executed before the section.
Returns a handle that can be used to remove the function via
off
.Frame.before(Frame.sim) {|delta| Log.print("delta:%(delta)") }
String
, fn: Fn
)
¶Handle
Connect a function to the specified section (with priority 0) which will be executed after the section.
Returns a handle that can be used to remove the function via
off
.Frame.after(Frame.sim) {|delta| Log.print("delta:%(delta)") }
Num
, fn: Fn
)
¶unknown
Once off. Queue a function to be called at the beginning of the frame
count_frames
from now, before any sections. This isFrame.next
but can push actions forward by frame count instead of time.Frame.skip(3) { Log.print("three frames from now!") }
String
, display: String
)
¶None
no docs found
Num
)
¶List
no docs found
Num
no docs found
Num
no docs found
FrameSection¶
import "luxe: game" for FrameSection
no docs found
String
An enum value for the
begin
section in the loop. The `begin section is the start of the frame from the game's perspective.Frame.on(Frame.begin) {|delta| ... }
String
An enum value for the
init
section in the loop. Theinit
section is used for initialization tasks that happen before updates, like when a new entity is created, it can be added to a queue and processed in init to set some default values before it arrives insim
orvisual
.Frame.on(Frame.init) {|delta| ... }
String
An enum value for the
sim
section in the loop. Thesim
section is for simulation, also known asupdate
. In this section you would update game logic and modify things that thevisual
section would reference.Frame.on(Frame.sim) {|delta| ... }
String
An enum value for the
visual
section in the loop. Thevisual
section is for rendering, also known asrender
. Updating visual state from the sim states happens here.Frame.on(Frame.visual) {|delta| ... }
String
An enum value for the
debug
section in the loop. Thedebug
part of the loop can perform debug related tasks before the end of the frame and rendering is submitted.Frame.on(Frame.debug) {|delta| ... }
String
An enum value for the
end
section in the loop. Theend
of the loop can perform tasks after rendering and simulation.Frame.on(Frame.end) {|delta| ... }
Any
)
¶unknown
no docs found
FrameWhen¶
import "luxe: game" for FrameWhen
no docs found
String
no docs found
String
no docs found
String
no docs found
String
no docs found
Any
)
¶unknown
no docs found
Ready¶
import "luxe: game" for Ready
The base class for a luxe game.
None
Called via
super()
inside yourready
function. Must be called.
String
)
¶None
Called via
super(message)
inside yourready
function. Must be called.
Num
)
¶None
A default implementation for tick.
None
A default implementation for destroy.