mutable decl syntax change
This commit is contained in:
@@ -79,8 +79,8 @@ read_command func() Command {
|
||||
if rl.IsMouseButtonPressed(rl.MOUSE_BUTTON_LEFT) return .spawn{ rl.GetMousePosition() }
|
||||
if rl.IsKeyPressed(rl.KEY_SPACE) return .clear
|
||||
|
||||
fx f32 = 0.0
|
||||
fy f32 = 0.0
|
||||
fx f32 := 0.0
|
||||
fy f32 := 0.0
|
||||
if rl.IsKeyDown(rl.KEY_A) fx -= FORCE
|
||||
if rl.IsKeyDown(rl.KEY_D) fx += FORCE
|
||||
if rl.IsKeyDown(rl.KEY_W) fy -= FORCE
|
||||
@@ -130,14 +130,14 @@ step func(b @mut Ball) void {
|
||||
|
||||
draw_ball func(b @Ball, highlight bool) void {
|
||||
col :: color_for(b.kind)
|
||||
center rl.Vector2 = rl.Vector2{ x = b.x, y = b.y }
|
||||
center rl.Vector2 := rl.Vector2{ x = b.x, y = b.y }
|
||||
match b.kind {
|
||||
.circle: rl.DrawCircleV(center, b.radius, col)
|
||||
.square: rl.DrawPoly(center, 4, b.radius, 45.0, col)
|
||||
.triangle: rl.DrawPoly(center, 3, b.radius, 0.0, col)
|
||||
}
|
||||
if highlight {
|
||||
ring rl.Color = rl.Color{ r = 250, g = 245, b = 200, a = 255 }
|
||||
ring rl.Color := rl.Color{ r = 250, g = 245, b = 200, a = 255 }
|
||||
rl.DrawPoly(center, 24, b.radius + RING_PAD, 0.0, ring)
|
||||
}
|
||||
}
|
||||
@@ -152,11 +152,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 :: rl.Color{ r = 24, g = 26, b = 34, a = 255 }
|
||||
text :: rl.Color{ r = 225, g = 225, b = 230, a = 255 }
|
||||
@@ -211,7 +211,7 @@ main func() i32 {
|
||||
# --- which shape is under the cursor? (optional via a value-loop) ---
|
||||
mouse :: rl.GetMousePosition()
|
||||
sel :: for 0..(count) |i| hover: {
|
||||
c rl.Vector2 = rl.Vector2{ x = balls[i].x, y = balls[i].y }
|
||||
c rl.Vector2 := rl.Vector2{ x = balls[i].x, y = balls[i].y }
|
||||
if rl.CheckCollisionPointCircle(mouse, c, balls[i].radius) yield :hover i
|
||||
yield null
|
||||
}
|
||||
@@ -222,7 +222,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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user