first commit

This commit is contained in:
2024-11-04 17:09:01 +03:00
commit e93a412ba6
4 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,62 @@
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()
}
}

36
examples/float/main.odin Normal file
View 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()
}
}

43
examples/vector/main.odin Normal file
View File

@ -0,0 +1,43 @@
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()
}
}