mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
a
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
|
||||
--My versions
|
||||
|
||||
type EaseFunction = (n: number) -> number
|
||||
type LinearFunction = (a: number, b: number, t: number) -> number
|
||||
type Ease = (n: number) -> number
|
||||
type Linear = (a: number, b: number, t: number) -> number
|
||||
|
||||
export type RotationMatrix = {
|
||||
Ixx: number,
|
||||
@@ -18,15 +18,22 @@ export type RotationMatrix = {
|
||||
|
||||
export type Scalar = {
|
||||
Distance: number,
|
||||
Center: Vector2,
|
||||
Center: Vector2,
|
||||
Rotation: number
|
||||
}
|
||||
|
||||
export type Easing = {
|
||||
Linear: Linear,
|
||||
InOutBack: Ease,
|
||||
OutBounce: Ease,
|
||||
InQuad: Ease,
|
||||
OutQuad: Ease,
|
||||
InOutQuad: Ease,
|
||||
InOutQuart: Ease,
|
||||
}
|
||||
|
||||
export type Math = {
|
||||
Linear: LinearFunction,
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction,
|
||||
InQuad: EaseFunction,
|
||||
Easing: Easing,
|
||||
IsOdd: (n: number) -> boolean,
|
||||
IsEven: (n: number) -> boolean,
|
||||
RotationMatrix: (X: number, Y: number, Z: number) -> RotationMatrix,
|
||||
@@ -36,7 +43,9 @@ export type Math = {
|
||||
minmax: (min: number, n: number, max: number) -> number
|
||||
}
|
||||
|
||||
local Math = {} :: Math
|
||||
local Math = {
|
||||
Easing = {}
|
||||
} :: Math
|
||||
|
||||
function Math.IsOdd(n)
|
||||
return bit32.btest(bit32.band(n, 1))
|
||||
@@ -81,24 +90,43 @@ function Math.LinearElapse(StartTime, Timing)
|
||||
end
|
||||
|
||||
--My versions
|
||||
function Math.Linear(a, b, t)
|
||||
function Math.Easing.Linear(a, b, t)
|
||||
return a-a*t+b*t
|
||||
end
|
||||
|
||||
local c = 2.59491
|
||||
function Math.InOutBack(n)
|
||||
function Math.Easing.InOutBack(n)
|
||||
return n<.5 and 2*n*n*(-c+2*n+2*c*n) or 3*(-1+n)*(-1+n)*(-2-c+2*n+2*c*n)
|
||||
end
|
||||
|
||||
local n1, d1 = 7.5625, 2.75
|
||||
function Math.OutBounce(n)
|
||||
function Math.Easing.OutBounce(n)
|
||||
return (n<0.363636 and n*n*n1 or
|
||||
n<0.727273 and (.75*(1.*d1-2.*n*n1)) or
|
||||
n<0.909091 and (.9375*(1.*d1-2.4*n*n1)/d1)) or (.984375*(1.*d1-2.66667*n*n1))/d1
|
||||
end
|
||||
|
||||
function Math.InQuad(n)
|
||||
function Math.Easing.InQuad(n)
|
||||
return n*n
|
||||
end
|
||||
|
||||
function Math.Easing.OutQuad(n)
|
||||
return -((-2+n)*n)
|
||||
end
|
||||
|
||||
function Math.Easing.InOutQuad(n)
|
||||
-- n<.5 and 2*n*n or -1-2*(-2+n)*n
|
||||
-- -n*math.abs(n)+n
|
||||
-- n-.5*n*math.abs(n)
|
||||
-- n-n*math.abs(n)
|
||||
|
||||
return n<.5 and 2*n*n or -1-2*(-2+n)*n
|
||||
end
|
||||
|
||||
function Math.Easing.InOutQuart(n)
|
||||
--n<.5 and 8*n*n*n*n or 1-(-2*n+2)*(-2*n+2)*(-2*n+2)*(-2*n+2)/2
|
||||
|
||||
return n<.5 and 8*n*n*n*n or 1-8*(-1+n)*(-1+n)*(-1+n)*(-1+n)
|
||||
end
|
||||
|
||||
return Math
|
||||
Reference in New Issue
Block a user