diff --git a/game.odin b/game.odin index a2631e7..5ef3198 100644 --- a/game.odin +++ b/game.odin @@ -578,8 +578,8 @@ update_positions :: proc(delta_t: time.Duration) { continue } if src.anim_timer < TILE_ANIM_DURATION { - src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) - src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) + src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) + src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) src.anim_timer += delta_t } else { dest := &game.board[cast(int)src.new_pos.x][cast(int)src.new_pos.y] @@ -619,8 +619,8 @@ update_positions :: proc(delta_t: time.Duration) { continue } if src.anim_timer < TILE_ANIM_DURATION { - src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) - src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) + src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) + src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) src.anim_timer += delta_t } else { dest := &game.board[cast(int)src.new_pos.x][cast(int)src.new_pos.y] @@ -660,8 +660,8 @@ update_positions :: proc(delta_t: time.Duration) { continue } if src.anim_timer < TILE_ANIM_DURATION { - src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) - src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) + src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) + src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) src.anim_timer += delta_t } else { dest := &game.board[cast(int)src.new_pos.x][cast(int)src.new_pos.y] @@ -701,8 +701,8 @@ update_positions :: proc(delta_t: time.Duration) { continue } if src.anim_timer < TILE_ANIM_DURATION { - src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) - src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, zephr.ease_out_cubic(cast(f32)src.anim_timer / cast(f32)TILE_ANIM_DURATION)) + src.position.x = math.lerp(src.start_pos.x, src.new_pos.x, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) + src.position.y = math.lerp(src.start_pos.y, src.new_pos.y, cast(f32)zephr.ease_in_out_back(cast(f64)src.anim_timer / cast(f64)TILE_ANIM_DURATION)) src.anim_timer += delta_t } else { dest := &game.board[cast(int)src.new_pos.x][cast(int)src.new_pos.y] diff --git a/zephr/zephr_math.odin b/zephr/zephr_math.odin index 236f977..9d0e4f6 100644 --- a/zephr/zephr_math.odin +++ b/zephr/zephr_math.odin @@ -194,3 +194,14 @@ ease_out_bounce :: proc(t: $T) -> T where intrinsics.type_is_numeric(T) { return n1 * (t) * t + 0.984375; } } + +ease_in_out_quint :: proc(t: f32) -> f32 { + return t < 0.5 ? 16 * t * t * t * t * t : 1 - math.pow(-2 * t + 2, 5) / 2 +} + +ease_in_out_back :: proc(t: f64) -> f64 { + c1 := 1.70158; + c2 := c1 * 1.525; + + return (math.pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2 if t < 0.5 else (math.pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2 +}