first commit
This commit is contained in:
36
examples/float/main.odin
Normal file
36
examples/float/main.odin
Normal file
@ -0,0 +1,36 @@
|
||||
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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user