ntween/examples/vector/main.odin

44 lines
777 B
Odin

package vectors
import nt "../../"
import "core:math/ease"
import "core:math/rand"
import rl "vendor:raylib"
main :: proc() {
rl.InitWindow(800, 600, "VECTORS")
rl.SetTargetFPS(60)
vec2 :: [2]f32
easings := [?]ease.Ease{.Sine_In_Out, .Bounce_Out, .Cubic_In, .Elastic_Out, .Linear}
tweens := nt.init([2]f32)
positions: [5]vec2
for &pos, i in positions {
pos.y = f32(i * 100 + 50)
pos.x = 100
nt.animate(
&tweens,
&pos,
vec2{rand.float32_range(100, 700), rand.float32_range(100, 500)},
5,
easings[i],
)
}
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()
}
}