.{random} := @use("../../../../libraries/stn/src/lib.hb") render := @use("../../../../libraries/render/src/lib.hb") /* expected result: a square that changes colour bounces around the screen */ example := fn(): void { render.init() vel := render.IVec2.(1, 1) pos := render.IVec2.(100, 100) width := render.width() height := render.height() color := @as(render.Color, @intcast(random.integer_range(0, 0xFFFFFF))) loop { render.put_filled_rect(pos, .(100, 100), color) render.sync() render.clear(render.black) if pos.x == 0 | pos.x == width - 100 { vel.x = -vel.x color = @as(render.Color, @intcast(random.integer_range(0, 0xFFFFFF))) } if pos.y == 0 | pos.y == height - 100 { vel.y = -vel.y color = @as(render.Color, @intcast(random.integer_range(0, 0xFFFFFF))) } pos += vel } return }