31 lines
734 B
Plaintext
31 lines
734 B
Plaintext
// To see what the result of parsing this file looks like, copy the code and
|
|
// paste it into the editor at https://flecs.dev/explorer
|
|
//
|
|
// To load this file yourself, call ecs_plecs_from_file("expressions.flecs");
|
|
|
|
using flecs.meta
|
|
|
|
// Create component types, see reflection example
|
|
Struct Position {
|
|
x :- {f32}
|
|
y :- {f32}
|
|
}
|
|
|
|
Struct Rectangle {
|
|
width :- {f32}
|
|
height :- {f32}
|
|
}
|
|
|
|
// Plecs files can contain variables that can be referenced later on when
|
|
// assigning values to components
|
|
const width = 5
|
|
|
|
// Variables and components can be assigned using expressions. Most arithmetic
|
|
// and conditional operators are supported.
|
|
const height = $width * 2
|
|
|
|
e {
|
|
- Position{0, -($height / 2)}
|
|
- Rectangle{$width, $height}
|
|
}
|