mutable decl syntax change

This commit is contained in:
2026-08-05 21:19:41 +02:00
parent 88b94197c9
commit 081a3fd5df
74 changed files with 870 additions and 733 deletions
+11 -11
View File
@@ -77,8 +77,8 @@ read_command func() Command {
if IsMouseButtonPressed(MOUSE_BUTTON_LEFT) return .spawn{ GetMousePosition() }
if IsKeyPressed(KEY_SPACE) return .clear
fx f32 = 0.0
fy f32 = 0.0
fx f32 := 0.0
fy f32 := 0.0
if IsKeyDown(KEY_A) fx -= FORCE
if IsKeyDown(KEY_D) fx += FORCE
if IsKeyDown(KEY_W) fy -= FORCE
@@ -128,14 +128,14 @@ step func(b @mut Ball) void {
draw_ball func(b @Ball, highlight bool) void {
col :: color_for(b.kind)
center Vector2 = Vector2{ x = b.x, y = b.y }
center Vector2 := Vector2{ x = b.x, y = b.y }
match b.kind {
.circle: DrawCircleV(center, b.radius, col)
.square: DrawPoly(center, 4, b.radius, 45.0, col)
.triangle: DrawPoly(center, 3, b.radius, 0.0, col)
}
if highlight {
ring Color = Color{ r = 250, g = 245, b = 200, a = 255 }
ring Color := Color{ r = 250, g = 245, b = 200, a = 255 }
DrawPoly(center, 24, b.radius + RING_PAD, 0.0, ring)
}
}
@@ -150,11 +150,11 @@ main func() i32 {
`[click] spawn a shape [WASD/arrows] blow wind
`[space] clear
balls [CAP]mut Ball = undefined
count usize = 0 # number of live balls, in slots 0..count
kc Kind = .circle # next kind to spawn
spin f32 = 1.0 # rotates spawn velocity for variety
at_cap bool = false # show the "at capacity" banner
balls [CAP]mut Ball := undefined
count usize := 0 # number of live balls, in slots 0..count
kc Kind := .circle # next kind to spawn
spin f32 := 1.0 # rotates spawn velocity for variety
at_cap bool := false # show the "at capacity" banner
bg :: Color{ r = 24, g = 26, b = 34, a = 255 }
text :: Color{ r = 225, g = 225, b = 230, a = 255 }
@@ -209,7 +209,7 @@ main func() i32 {
# --- which shape is under the cursor? (optional via a value-loop) ---
mouse :: GetMousePosition()
sel :: for 0..(count) |i| blk: {
c Vector2 = Vector2{ x = balls[i].x, y = balls[i].y }
c Vector2 := Vector2{ x = balls[i].x, y = balls[i].y }
if CheckCollisionPointCircle(mouse, c, balls[i].radius) yield :blk i
yield null
}
@@ -220,7 +220,7 @@ main func() i32 {
for (&balls) |@b, i| {
if (i >= count) break
hot bool = false
hot bool := false
if sel |s| {
if (s == i) hot = true # true only for the hovered ball
}