val everyone: list[Person] = new(size:50, step:25, max:250)
enum Emotion {
Relaxed, Happy, Angry, Distress
}
type Vector[T:int|num] byRef: tuple {
var
x, y, z: T
init
cross(a, b:Vector) = a.(x, y, z) * b.(x, y, z)
func
cross() = (x, y, z) *= (x, y, z)
cross(v:Vector) = (x, y, z) *= v.(x, y, z)
+=(n:T) = (x, y, z) += n
+=(v:Vector) = (x, y, z) += v.(x, y, z)
-=(n:T) = (x, y, z) -= n
-=(v:Vector) = (x, y, z) -= v.(x, y, z)
}
type Person {
var
name = "Unknown"
age pri: num
emotion pub: Emotion
position pub: Vector
init
new(.name, .age = 0, .position = 0) pool(everyone)
fini
die() pool(everyone)
func
greet() =
echo "Hello, I'm ", name, "."
echo "I am ", age, " years old."
proc
update() required =
position += World.gravity * Time.delta
collide(hits:list[Collision]) optional {
for hit in hits:
if hit.item is Enemy: die()
}
}
Last active
August 29, 2015 13:59
-
-
Save PhilipWitte/10698296 to your computer and use it in GitHub Desktop.
random syntax thoughts
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment