Skip to content

luxe: game


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 or on ordering.

Note: This API is a work in progress.

Frame.begin : 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| ... }

Frame.init : String

An enum value for the init section in the loop. The init 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 in sim or visual.

Frame.on(Frame.init) {|delta| ... }

Frame.sim : String

An enum value for the sim section in the loop. The sim section is for simulation, also known as update. In this section you would update game logic and modify things that the visual section would reference.

Frame.on(Frame.sim) {|delta| ... }

Frame.visual : String

An enum value for the visual section in the loop. The visual section is for rendering, also known as render. Updating visual state from the sim states happens here.

Frame.on(Frame.visual) {|delta| ... }

Frame.debug : String

An enum value for the debug section in the loop. The debug part of the loop can perform debug related tasks before the end of the frame and rendering is submitted.

Frame.on(Frame.debug) {|delta| ... }

Frame.end : String

An enum value for the end section in the loop. The end of the loop can perform tasks after rendering and simulation.

Frame.on(Frame.end) {|delta| ... }

Frame.queue(fn : 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 after before on and after.

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() }
}
}

Frame.next(fn : 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) }
}

Frame.end(fn : 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!")
}

Frame.schedule(time : 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 other schedule method.

Frame.schedule(time : 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. If count is 0, the function will be called repeatedly until unschedule is called.

Frame.unschedule(handle : Handle) : None

Unschedule a function scheduled previously, using the handle returned from schedule.

Frame.off(handle : 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)

Frame.once(section : 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") }

Frame.on(section : 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") }

Frame.before(section : 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") }

Frame.after(section : 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") }

Frame.on(section : 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)") }

Frame.once(section : 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'") }

Frame.before(section : 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)") }

Frame.after(section : 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)") }

Frame.skip(count_frames : 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 is Frame.next but can push actions forward by frame count instead of time.

Frame.skip(3) {
Log.print("three frames from now!")
}

Frame.mark(id : String, display : String) : None

no docs found

Frame.get_marks(frame_index : Num) : List

no docs found

Frame.index : Num

no docs found

Frame.delta : Num

no docs found

import "luxe: game" for FrameSection

no docs found

FrameSection.begin : 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| ... }

FrameSection.init : String

An enum value for the init section in the loop. The init 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 in sim or visual.

Frame.on(Frame.init) {|delta| ... }

FrameSection.sim : String

An enum value for the sim section in the loop. The sim section is for simulation, also known as update. In this section you would update game logic and modify things that the visual section would reference.

Frame.on(Frame.sim) {|delta| ... }

FrameSection.visual : String

An enum value for the visual section in the loop. The visual section is for rendering, also known as render. Updating visual state from the sim states happens here.

Frame.on(Frame.visual) {|delta| ... }

FrameSection.debug : String

An enum value for the debug section in the loop. The debug part of the loop can perform debug related tasks before the end of the frame and rendering is submitted.

Frame.on(Frame.debug) {|delta| ... }

FrameSection.end : String

An enum value for the end section in the loop. The end of the loop can perform tasks after rendering and simulation.

Frame.on(Frame.end) {|delta| ... }

FrameSection.name(value : Any) : unknown

no docs found

import "luxe: game" for FrameWhen

no docs found

FrameWhen.unknown : String

no docs found

FrameWhen.before : String

no docs found

FrameWhen.on : String

no docs found

FrameWhen.after : String

no docs found

FrameWhen.name(value : Any) : unknown

no docs found

import "luxe: game" for Ready

The base class for a luxe game.

Ready.ready() : None

Called via super() inside your ready function. Must be called.

Ready.ready(message : String) : None

Called via super(message) inside your ready function. Must be called.

Ready.tick(delta : Num) : None

A default implementation for tick.

Ready.destroy() : None

A default implementation for destroy.