mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 06:41:55 +00:00
226 lines
7.9 KiB
Lua
226 lines
7.9 KiB
Lua
--!optimize 2
|
|
--!native
|
|
--!strict
|
|
|
|
--Not a good idea to call modules from other services here
|
|
|
|
type RotationMatrix = {
|
|
Ixx: number,
|
|
Ixy: number,
|
|
Iyx: number,
|
|
Iyy: number,
|
|
Izx: number,
|
|
Izy: number
|
|
}
|
|
|
|
type Scalar = {
|
|
Distance: number,
|
|
Center: Vector2,
|
|
Rotation: number
|
|
}
|
|
|
|
type GuiDependencies = {
|
|
IntroGui: ScreenGui,
|
|
Frame: Frame,
|
|
FrameGradient: UIGradient,
|
|
TextShadow: TextLabel,
|
|
ShadowGradient: UIGradient,
|
|
FrameworkText: TextLabel,
|
|
SandboxText: TextLabel,
|
|
DeveloperText: TextLabel,
|
|
Quaternions: ImageLabel,
|
|
TaylorSeries: ImageLabel,
|
|
Xframe: Frame,
|
|
Yframe: Frame,
|
|
Zframe: Frame,
|
|
Xframe_text: TextLabel,
|
|
Yframe_text: TextLabel,
|
|
Zframe_text: TextLabel,
|
|
}
|
|
|
|
local RS = game:GetService("RunService")
|
|
local Storage = game:GetService("ReplicatedStorage")
|
|
local TS = game:GetService("TestService")
|
|
local CoP = game:GetService("ContentProvider")
|
|
|
|
local LoadingFun = true
|
|
|
|
local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
|
IntroGui.Enabled = true
|
|
|
|
local Frame = IntroGui:WaitForChild("Frame") :: Frame
|
|
|
|
local FrameGradient = Frame:WaitForChild("UIGradient") :: UIGradient
|
|
local TextShadow = Frame:WaitForChild("TextShadow") :: TextLabel
|
|
local FrameworkText = Frame:WaitForChild("Framework") :: TextLabel
|
|
local SandboxText = Frame:WaitForChild("Sandbox") :: TextLabel
|
|
local DeveloperText = Frame:WaitForChild("Developer") :: TextLabel
|
|
local ShadowGradient = TextShadow:WaitForChild("UIGradient") :: UIGradient
|
|
local Quaternions = Frame:WaitForChild("Quaternions") :: ImageLabel
|
|
local TaylorSeries = Frame:WaitForChild("TaylorSeries") :: ImageLabel
|
|
|
|
local Xframe = Frame:WaitForChild("X") :: Frame
|
|
local Yframe = Frame:WaitForChild("Y") :: Frame
|
|
local Zframe = Frame:WaitForChild("Z") :: Frame
|
|
|
|
local Xframe_text = Frame:WaitForChild("X_text") :: TextLabel
|
|
local Yframe_text = Frame:WaitForChild("Y_text") :: TextLabel
|
|
local Zframe_text = Frame:WaitForChild("Z_text") :: TextLabel
|
|
|
|
return {
|
|
IntroGui = IntroGui,
|
|
Frame = Frame,
|
|
FrameGradient = FrameGradient,
|
|
TextShadow = TextShadow,
|
|
ShadowGradient = ShadowGradient,
|
|
FrameworkText = FrameworkText,
|
|
SandboxText = SandboxText,
|
|
DeveloperText = DeveloperText,
|
|
Quaternions = Quaternions,
|
|
TaylorSeries = TaylorSeries,
|
|
Xframe = Xframe,
|
|
Yframe = Yframe,
|
|
Zframe = Zframe,
|
|
Xframe_text = Xframe_text,
|
|
Yframe_text = Yframe_text,
|
|
Zframe_text = Zframe_text,
|
|
}
|
|
end
|
|
|
|
local Size = 300
|
|
local WorldSize = 3
|
|
|
|
local function GUI_LoadFinish(Gui: GuiDependencies) --We can now access the framework
|
|
--Image if we had HTML and CSS...
|
|
local Tween = require(Storage:WaitForChild("Tween"))
|
|
|
|
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
|
BackgroundTransparency = 1
|
|
})
|
|
|
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
|
TextTransparency = 1
|
|
}):Start()
|
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.TaylorSeries, {
|
|
ImageTransparency = 1
|
|
}):Start()
|
|
Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Quaternions, {
|
|
ImageTransparency = 1
|
|
}):Start()
|
|
|
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Xframe_text, {
|
|
TextTransparency = 1
|
|
}):Start()
|
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Yframe_text, {
|
|
TextTransparency = 1
|
|
}):Start()
|
|
Tween.constructor(TweenInfo.new(.5, Enum.EasingStyle.Linear), Gui.Zframe_text, {
|
|
TextTransparency = 1
|
|
}):Start()
|
|
|
|
local FrameTween = FrameTween_Constructor:Start()
|
|
|
|
--Text deleting effect
|
|
task.spawn(function()
|
|
for n: number = #Gui.SandboxText.Text, 1, -1 do --"A sandbox experience" has the longest text
|
|
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,n-1)
|
|
if #Gui.FrameworkText.Text ~= 0 then
|
|
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,n-1)
|
|
Gui.TextShadow.Text = Gui.FrameworkText.Text --heh hack
|
|
end
|
|
task.wait(.05)
|
|
end
|
|
end)
|
|
|
|
task.spawn(function()
|
|
while task.wait() do
|
|
Size = math.max(0, Size-5)
|
|
end
|
|
end)
|
|
|
|
FrameTween.Completed:Wait()
|
|
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
|
script.Parent:Destroy()
|
|
end
|
|
|
|
local function RotationMatrix(X: number, Y: number, Z: number): RotationMatrix
|
|
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)
|
|
}
|
|
end
|
|
|
|
local function Scalar(X1: number, Y1: number, X2: number, Y2: number): Scalar
|
|
return {
|
|
Distance = math.sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
|
|
Center = Vector2.new((X1+X2)/2,(Y1+Y2)/2);
|
|
Rotation = math.deg(math.atan2(Y1-Y2,X1-X2))
|
|
}
|
|
end
|
|
|
|
local function UI_3D_Rotation(Gui: GuiDependencies, Delta: number)
|
|
local ScreenD = workspace.CurrentCamera.ViewportSize
|
|
local CenterX = ScreenD.X/2
|
|
local CenterY = ScreenD.Y/1.4
|
|
local mX = Delta/1.5
|
|
local mY = Delta/1.5
|
|
local mZ = -7.65
|
|
|
|
local RMatrix = RotationMatrix(mX,mY,mZ)
|
|
local X = {Size*RMatrix.Ixx, Size*RMatrix.Ixy}
|
|
local Y = {Size*RMatrix.Iyx, Size*RMatrix.Iyy}
|
|
local Z = {Size*RMatrix.Izx, Size*RMatrix.Izy}
|
|
|
|
local AXIS_R_3DScalar_X = Scalar(CenterX+X[1],CenterY+X[2],CenterX,CenterY)
|
|
local AXIS_R_3DScalar_Y = Scalar(CenterX+Y[1],CenterY+Y[2],CenterX,CenterY)
|
|
local AXIS_R_3DScalar_Z = Scalar(CenterX+Z[1],CenterY+Z[2],CenterX,CenterY)
|
|
|
|
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
|
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
|
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
|
|
|
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
|
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
|
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
|
|
|
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
|
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
|
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
|
|
|
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
|
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
|
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
|
|
|
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
|
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
|
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
|
end
|
|
|
|
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
|
local Gui = GuiDependencies(IntroGui)
|
|
|
|
RS.Stepped:Connect(function(Delta: number, _dt: number)
|
|
UI_3D_Rotation(Gui, Delta)
|
|
end)
|
|
|
|
task.spawn(function()
|
|
CoP:PreloadAsync({Gui.TaylorSeries, Gui.Quaternions}) --Try as early as possible
|
|
|
|
if not game:IsLoaded() then
|
|
game.Loaded:Wait()
|
|
end
|
|
|
|
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
|
|
end
|
|
|
|
TS:Message("Load elapse: "..tostring(load_elapse), game)
|
|
|
|
GUI_LoadFinish(Gui)
|
|
end)
|
|
end |