mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
Faster RotationMatrix, IsEven bit shift and, work on MakeProperty module
This commit is contained in:
@@ -144,13 +144,17 @@ local function GUI_LoadFinish(Gui: GuiDependencies) --We can now access the fram
|
||||
end
|
||||
|
||||
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
local cosX, sinX = math.cos(X), math.sin(X)
|
||||
local cosY, sinY = math.cos(Y), math.sin(Y)
|
||||
local cosZ, sinZ = math.cos(Z), math.sin(Z)
|
||||
|
||||
return {
|
||||
Ixx = math.cos(Z)*math.cos(X)-math.sin(Z)*math.sin(X)*math.sin(Y);
|
||||
Ixy = math.cos(Z)*math.sin(X)*math.sin(Y)+math.sin(Z)*math.cos(X);
|
||||
Iyx = -math.cos(Z)*math.sin(X)-math.sin(Z)*math.cos(X)*math.sin(Y);
|
||||
Iyy = math.cos(Z)*math.cos(X)*math.sin(Y)-math.sin(Z)*math.sin(X);
|
||||
Izx = -math.sin(Z)*math.cos(Y);
|
||||
Izy = math.cos(Z)*math.sin(Y)
|
||||
Ixx = cosZ*cosX-sinZ*sinX*sinY,
|
||||
Ixy = cosZ*sinX*sinY+sinZ*cosX,
|
||||
Iyx = -cosZ*sinX-sinZ*cosX*sinY,
|
||||
Iyy = cosZ*cosX*sinY-sinZ*sinX,
|
||||
Izx = -sinZ*cosY,
|
||||
Izy = cosZ*sinY
|
||||
}
|
||||
end
|
||||
|
||||
@@ -216,7 +220,7 @@ return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||
|
||||
local load_elapse = os.clock()-load_elapse_start
|
||||
if LoadingFun then
|
||||
task.wait(math.max(0, 4-load_elapse)) --Only if you take longer than or exactly 4 seconds to load
|
||||
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 4 seconds to load
|
||||
end
|
||||
|
||||
TS:Message("Load elapse: "..tostring(load_elapse), game)
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
type Head = BasePart
|
||||
type UpperTorso = BasePart
|
||||
type Neck = Motor6D
|
||||
type Waist = Motor6D
|
||||
type NeckC0 = CFrame
|
||||
type WaistC0 = CFrame
|
||||
type UDP = UnreliableRemoteEvent
|
||||
type Head = BasePart
|
||||
type UpperTorso = BasePart
|
||||
type Neck = Motor6D
|
||||
type Waist = Motor6D
|
||||
type NeckC0 = CFrame
|
||||
type WaistC0 = CFrame
|
||||
type UDP = UnreliableRemoteEvent
|
||||
type CharacterShared = Folder
|
||||
|
||||
type struct_SpineMovement = {
|
||||
Neck: CFrame,
|
||||
@@ -23,7 +24,7 @@ type Impl_Constructor = {
|
||||
Move: (self: ClassConstructor, CameraCFrame: CFrame, IsFirstPerson: boolean) -> ()
|
||||
} & Impl_Static_Props
|
||||
|
||||
type Constructor_Fun = (Head: Head, UpperTorso: UpperTorso) -> ClassConstructor
|
||||
type Constructor_Fun = (CharacterShared: CharacterShared, Head: Head, UpperTorso: UpperTorso) -> ClassConstructor
|
||||
type Impl_Static_Props = {
|
||||
Enabled: boolean,
|
||||
Multiplier: number
|
||||
@@ -46,17 +47,16 @@ Spine.__index = Spine
|
||||
Spine.Enabled = true
|
||||
Spine.Multiplier = .5
|
||||
|
||||
local Remote = Instance.new("UnreliableRemoteEvent") :: UDP
|
||||
Remote.Name = "SpineStream"
|
||||
Remote.Parent = _G.include(script, "CharacterShared")
|
||||
|
||||
function Spine.constructor(Head, UpperTorso)
|
||||
function Spine.constructor(CharacterShared, Head, UpperTorso)
|
||||
local self = {}
|
||||
self.Remote = Instance.new("UnreliableRemoteEvent") :: UDP
|
||||
self.Remote.Name = "SpineStream"
|
||||
self.Remote.Parent = CharacterShared
|
||||
|
||||
self.Head = Head
|
||||
self.UpperTorso = UpperTorso
|
||||
self.Neck = Head:WaitForChild("Neck") :: Motor6D
|
||||
self.Waist = UpperTorso:WaitForChild("Waist") :: Motor6D
|
||||
self.Remote = Remote
|
||||
self.NeckC0 = (self.Neck :: Motor6D).C0
|
||||
self.WaistC0 = (self.Neck :: Motor6D).C0
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ function Character.constructor(CharacterModel)
|
||||
local HumanoidRootPart = CharacterModel:WaitForChild("HumanoidRootPart") :: HumanoidRootPart
|
||||
|
||||
self.CharacterShadows = Shadows.constructor(CharacterModel)
|
||||
self.Spine = SpineModule.constructor(Head, UpperTorso)
|
||||
self.Spine = SpineModule.constructor(self.CharacterShared, Head, UpperTorso)
|
||||
self.Flashlight = FlashlightModule.constructor(self.CharacterShared, Player, HumanoidRootPart)
|
||||
self.Actions = ActionsModule.constructor(self.CharacterShared, Player)
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ export type Math = {
|
||||
InOutBack: EaseFunction,
|
||||
OutBounce: EaseFunction,
|
||||
InQuad: EaseFunction,
|
||||
IsEven: (n: number) -> boolean,
|
||||
RotationMatrix: (X: number, Y: number, Z: number) -> RotationMatrix,
|
||||
Scalar: (X1: number, Y1: number, X2: number, Y2: number) -> Scalar,
|
||||
maxmin: (min: number, n: number, max: number) -> number
|
||||
@@ -34,18 +35,26 @@ export type Math = {
|
||||
|
||||
local Math = {} :: Math
|
||||
|
||||
function Math.IsEven(n)
|
||||
return bit32.band(n, 1) == 0
|
||||
end
|
||||
|
||||
function Math.maxmin(min, n, max)
|
||||
return math.max(min, math.min(n, max))
|
||||
end
|
||||
|
||||
function Math.RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
||||
local cosX, sinX = math.cos(X), math.sin(X)
|
||||
local cosY, sinY = math.cos(Y), math.sin(Y)
|
||||
local cosZ, sinZ = math.cos(Z), math.sin(Z)
|
||||
|
||||
return {
|
||||
Ixx = math.cos(Z)*math.cos(X)-math.sin(Z)*math.sin(X)*math.sin(Y);
|
||||
Ixy = math.cos(Z)*math.sin(X)*math.sin(Y)+math.sin(Z)*math.cos(X);
|
||||
Iyx = -math.cos(Z)*math.sin(X)-math.sin(Z)*math.cos(X)*math.sin(Y);
|
||||
Iyy = math.cos(Z)*math.cos(X)*math.sin(Y)-math.sin(Z)*math.sin(X);
|
||||
Izx = -math.sin(Z)*math.cos(Y);
|
||||
Izy = math.cos(Z)*math.sin(Y)
|
||||
Ixx = cosZ*cosX-sinZ*sinX*sinY,
|
||||
Ixy = cosZ*sinX*sinY+sinZ*cosX,
|
||||
Iyx = -cosZ*sinX-sinZ*cosX*sinY,
|
||||
Iyy = cosZ*cosX*sinY-sinZ*sinX,
|
||||
Izx = -sinZ*cosY,
|
||||
Izy = cosZ*sinY
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
13
src/shared/MakeProperty.lua
Normal file
13
src/shared/MakeProperty.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
--[[
|
||||
Module.Property = MakeProperty.constructor()
|
||||
]]
|
||||
|
||||
local function MakeProperty<T>()
|
||||
|
||||
end
|
||||
|
||||
return MakeProperty
|
||||
@@ -1,24 +0,0 @@
|
||||
--!optimize 2
|
||||
--!native
|
||||
--!strict
|
||||
|
||||
local StringModule = {}
|
||||
StringModule.__index = StringModule
|
||||
|
||||
function StringModule.new(String: string)
|
||||
return setmetatable({
|
||||
String = String
|
||||
}, StringModule)
|
||||
end
|
||||
|
||||
type ByteArray = {string}
|
||||
|
||||
function StringModule:bytes(): ByteArray
|
||||
local cbytes = {self.String:byte(1,-1)}
|
||||
for i = 1, #cbytes do
|
||||
cbytes[i] = tostring(cbytes[i]):char()
|
||||
end
|
||||
return cbytes
|
||||
end
|
||||
|
||||
return StringModule
|
||||
Reference in New Issue
Block a user