using - template which essentially "from EXPR import nil" + some selection
part - macro which defines a part of the app/game (corresponds, by name, to editor data)
mode - built-in part state system component (multi-state. easy transition declaration)
on - app/game event logic (can be user-defined in editor)
Note: both name
and age
can be initialized by an editor or setup file.
using Console: write
part Person:
var
name: string,
age: int
on start:
write("Hi, my name is $name.")
write("I am $age years old.")
using Parts, Space, Timer
using Keyboard: Keys
part Ship:
const
speed = 4.3
var
space = Space.random(World.bounds)
model = Model.load("ships/XWing.mdl")
lasers = list[Laser].new(dynamic, reserve:50)
on update:
if Keyboard.key(A).isHeld: space.moveLeft(speed)
if Keyboard.key(D).isHeld: space.moveRight(speed)
if Keyboard.key(W).isHeld: space.moveForward(speed)
if Keyboard.key(S).isHeld: space.moveBackward(speed)
if Keyboard.key(Space).isPressed: lasers += Laser
on model.collide: die
part Ship.Laser:
const
speed = 24.8
var
space: Space
timer: Timer
on start:
space = base.model.nextFireSpot
timer = Timer.start(10, Seconds)
on update:
if timer.isDone:
base.lasers -= this
else:
space.moveForward(speed)
using App.Panel
using UI.Buttons
part Light:
var
isOn = false
brightness = 0.0
button = Panel.find(Button, "ClickMe")
proc turnOn() =
mode = On
proc turnOff() =
mode = Off
mode On:
goal 2, Seconds:
isOn = hold true
brightness = blend 1.0
mode Off:
goal 2, Seconds:
isOn = hold false
brightness = blend 0.0
on button.click:
mode.toggle()
on setup:
# global setup
spawn Light