Scenes & Entities
Scenes are the foundation of labelle games. They define what entities exist and how they’re configured.
Scene Definition
Section titled “Scene Definition”Scenes are defined in .zon files in the scenes/ directory:
.{ .name = "level1", .scripts = .{"gravity", "collision"}, .camera = .{ .x = 0, .y = 0, .zoom = 1.0 }, .entities = .{ .{ .id = "player", .prefab = "player", .components = .{ .Position = .{ .x = 100, .y = 100 } }, }, .{ .prefab = "enemy", .components = .{ .Position = .{ .x = 500, .y = 100 } }, }, },}Entity Types
Section titled “Entity Types”Prefab Reference
Section titled “Prefab Reference”Reference a prefab template with optional component overrides:
.{ .prefab = "player", .components = .{ .Position = .{ .x = 100, .y = 100 } } }Inline Entity
Section titled “Inline Entity”Define an entity directly without a prefab:
.{ .components = .{ .Position = .{ .x = 200, .y = 200 }, .Shape = .{ .type = .circle, .radius = 50 }, },}Entity IDs
Section titled “Entity IDs”Named entities can be looked up at runtime:
if (scene.getEntityByName("player")) |player| { // Do something with player}Scene Transitions
Section titled “Scene Transitions”Change scenes using the Game API:
game.queueSceneChange("level2");Camera Configuration
Section titled “Camera Configuration”Set camera position and zoom:
.camera = .{ .x = 0, .y = 0, .zoom = 2.0 }Or use named cameras for split-screen:
.cameras = .{ .main = .{ .x = 0, .y = 0 }, .player2 = .{ .x = 100, .y = 0 },}