Skip to content
Flecs v4.1
script/03_variables

  • Flecs Script

    View on GitHub

    // Scripts can contain variables that can be used in expressions.
    // Create a few component types
    struct Position(x: f32, y: f32)
    struct Rect(width: f32, height: f32)
    // A variable.
    const height: i32 = 5
    // If no type is specified, it will be inferred from the expression.
    const width = height * 2
    e {
    Position: {0, height / 2}
    Rect: {width, height}
    }