Structs
Point: struct {
x: float
y: float
}point0 := new Point {
x: 100
y: 200
}
point1: Point = new Point {
x: 1
y: 2
}point := new Point {
x: 100
y: 100
}
point x = 20
point y = point xLast updated
Point: struct {
x: float
y: float
}point0 := new Point {
x: 100
y: 200
}
point1: Point = new Point {
x: 1
y: 2
}point := new Point {
x: 100
y: 100
}
point x = 20
point y = point xLast updated
Vector: struct {
x: float,
y: float
}
implement Vector {
new: fun(x, y) -> Self {
Vector {
x: x,
y: y
}
}
length: fun(self) -> float {
(self x^2 + self y^2)^0.5
}
normalize: fun(self) {
len := self length()
self x /= len
self y /= len
}
}
a := Vector new(100, 100)
a normalize()