ntween/examples/float/main.odin

37 lines
885 B
Odin
Raw Permalink Normal View History

2024-11-04 17:09:01 +03:00
package floats
import nt "../../"
import "core:math/ease"
import rl "vendor:raylib"
main :: proc() {
rl.InitWindow(800, 600, "FLOATS")
rl.SetTargetFPS(60)
vec2 :: [2]f32
easings := [?]ease.Ease{.Sine_In_Out, .Bounce_Out, .Cubic_In, .Elastic_Out, .Linear} // Just a list of various easings
tweens := nt.init(f32) // Make a map of tweens. Can be used to animage single f32 values
positions: [5]vec2
for &pos, i in positions {
pos.y = f32(i * 100 + 50)
pos.x = 100
nt.animate(&tweens, &pos.x, 700, 5, easings[i]) // Animating all the positions with different easings
}
for !rl.WindowShouldClose() {
delta := rl.GetFrameTime()
nt.process(&tweens, delta) // Needs to be called every frame with delta time as argument
rl.BeginDrawing()
rl.ClearBackground(rl.BLACK)
for x in positions {
rl.DrawRectangleV(x, {20, 20}, rl.WHITE)
}
rl.EndDrawing()
}
}