aboutsummaryrefslogtreecommitdiff
path: root/src/math.odin
blob: fd81ac815f5e9b95fb9370ffe59d992577d57004 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package demonchime

import "core:math"
import "core:math/linalg"
import "core:math/rand"

import "fw"

dt_lerp :: proc {
  dt_lerp_f32,
  dt_lerp_arr,
}

dt_lerp_f32 :: proc(a: f32, b: f32, t: f32) -> f32 {
  dt := f32(fw.get_delta_time())
  return math.lerp(b, a, math.pow(0.5, dt * t))
}

dt_lerp_arr :: proc(a: [$N]$T, b: [N]T, t: T) -> [N]T {
  dt := T(fw.get_delta_time())
  return linalg.lerp(b, a, math.pow(0.5, dt * t))
}

coin_flip :: proc(rng := context.random_generator) -> bool {
  return rand.int32_range(1, 3) == 1
}