package vectors import nt "../../" import "core:math/ease" import "core:math/rand" import rl "vendor:raylib" vec2 :: [2]f32 easings := [?]ease.Ease{.Sine_In_Out, .Bounce_Out, .Cubic_In, .Elastic_Out, .Linear} pos_target :: struct { value: ^vec2, target: vec2, } tweens: nt.Tween_Map(vec2) main :: proc() { rl.InitWindow(800, 600, "VECTORS") rl.SetTargetFPS(60) tweens := nt.init(vec2) defer nt.destroy_tweens(&tweens) positions: [5]vec2 for &pos, i in positions { pos.y = f32(i * 100 + 50) pos.x = 100 target := new(pos_target) target.value = &pos target.target = pos nt.animate( &tweens, &pos, vec2{rand.float32_range(100, 700), rand.float32_range(100, 500)}, 1 + f32(i) / 5, easings[i], &pos, proc(data: rawptr) { p := transmute(^vec2)data nt.animate(&tweens, p, vec2{100, 100}, 1) }, ) } for !rl.WindowShouldClose() { delta := rl.GetFrameTime() nt.process(&tweens, delta) rl.BeginDrawing() rl.ClearBackground(rl.BLACK) for x in positions { rl.DrawRectangleV(x, {20, 20}, rl.WHITE) } rl.EndDrawing() } }