Tween library for Odin lang
Go to file
Nefrace 7136c68f3e Fixed readme 2024-11-04 17:25:17 +03:00
examples first commit 2024-11-04 17:09:01 +03:00
README.md Fixed readme 2024-11-04 17:25:17 +03:00
ntween.odin first commit 2024-11-04 17:09:01 +03:00

README.md

NTween

A simple library implementing tweens for Odin language.

There's already flux-tween in the standard library, but it was somewhat difficult to understand at first so I've made one myself.

Features

  • basic float values tweening
  • array values tweening (vec2 and vec3 for example)
  • supports easings from core:math/ease
  • callbacks after completion

Installing

You can clone this repo inside of your project and then just import the library using import ntween

How it works?

Check out examples folder. The callbacks one is not working right now but it's gonna be fixed.

Very basic example

package main

import nt "ntween"
import rl "vendor:raylib"
import "core:math/ease"

main :: proc() {
    rl.InitWindow(800, 600, "hellope, tweens!")
    
    tw := nt.init(f32)
    pos : f32 = 100.0
    
    nt.animate(&tw, &pos, 700, 2, ease.Ease.Bounce_Out)


    for !rl.WindowShouldClose() {
      delta := rl.GetFrameTime()
      nt.process(&tw, delta)

      rl.BeginDrawing()
      rl.ClearBackground(rl.BLACK)
      rl.DrawRectangleV({pos, 100}, {30, 30}, rl.WHITE)
      rl.EndDrawing()
    }
}