mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-15 21:31:54 +00:00
Rotation matrix UI and Interactions dir
This commit is contained in:
@@ -4,7 +4,39 @@
|
||||
|
||||
--Not a good idea to call modules from other services here
|
||||
|
||||
--Who said UI on here cant look like a web design lole,
|
||||
type RotationMatrix = {
|
||||
Ixx: number,
|
||||
Ixy: number,
|
||||
Iyx: number,
|
||||
Iyy: number,
|
||||
Izx: number,
|
||||
Izy: number
|
||||
}
|
||||
|
||||
type Scalar = {
|
||||
Distance: number,
|
||||
Center: Vector2,
|
||||
Rotation: number
|
||||
}
|
||||
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
type GuiDependencies = {
|
||||
IntroGui: ScreenGui,
|
||||
Frame: Frame,
|
||||
FrameGradient: UIGradient,
|
||||
TextShadow: TextLabel,
|
||||
ShadowGradient: UIGradient,
|
||||
FrameworkText: TextLabel,
|
||||
SandboxText: TextLabel,
|
||||
DeveloperText: TextLabel,
|
||||
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")
|
||||
@@ -12,101 +44,138 @@ local TS = game:GetService("TestService")
|
||||
|
||||
local LoadingFun = true
|
||||
|
||||
local function GuiDependencies(IntroGui: ScreenGui)
|
||||
local function GuiDependencies(IntroGui: ScreenGui): GuiDependencies
|
||||
IntroGui.Enabled = true
|
||||
|
||||
local Frame = IntroGui:WaitForChild("Frame")
|
||||
local Viewport = Frame:WaitForChild("ViewportFrame")
|
||||
local Frame = IntroGui:WaitForChild("Frame") :: Frame
|
||||
|
||||
local FrameGradient = Frame:WaitForChild("UIGradient")
|
||||
local TextShadow = Frame:WaitForChild("TextShadow")
|
||||
local FrameworkText = Frame:WaitForChild("Framework")
|
||||
local SandboxText = Frame:WaitForChild("Sandbox")
|
||||
local DeveloperText = Frame:WaitForChild("Developer")
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient")
|
||||
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 ViewportCamera = Instance.new("Camera")
|
||||
ViewportCamera.FieldOfView = 50
|
||||
ViewportCamera.Parent = Viewport
|
||||
Viewport.CurrentCamera = ViewportCamera
|
||||
local Xframe = Frame:WaitForChild("X") :: Frame
|
||||
local Yframe = Frame:WaitForChild("Y") :: Frame
|
||||
local Zframe = Frame:WaitForChild("Z") :: Frame
|
||||
|
||||
local GL_Cube = Viewport:WaitForChild("GL_Cube")
|
||||
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,
|
||||
Viewport = Viewport,
|
||||
ViewportCamera = ViewportCamera,
|
||||
GL_Cube = GL_Cube,
|
||||
FrameGradient = FrameGradient,
|
||||
TextShadow = TextShadow,
|
||||
ShadowGradient = ShadowGradient,
|
||||
FrameworkText = FrameworkText,
|
||||
SandboxText = SandboxText,
|
||||
DeveloperText = DeveloperText
|
||||
DeveloperText = DeveloperText,
|
||||
Xframe = Xframe,
|
||||
Yframe = Yframe,
|
||||
Zframe = Zframe,
|
||||
Xframe_text = Xframe_text,
|
||||
Yframe_text = Yframe_text,
|
||||
Zframe_text = Zframe_text,
|
||||
}
|
||||
end
|
||||
|
||||
type GUIs = typeof(GuiDependencies)
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs) --We can now access the framework
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GuiDependencies) --We can now access the framework
|
||||
--Image if we had HTML and CSS...
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
|
||||
local EaseStyle = Enum.EasingStyle.Linear
|
||||
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.Frame, {
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.Frame, {
|
||||
BackgroundTransparency = 1
|
||||
})
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.DeveloperText, {
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, Enum.EasingStyle.Linear), Gui.DeveloperText, {
|
||||
TextTransparency = 1
|
||||
})
|
||||
local ViewportFrame_Constructor = Tween.constructor(TweenInfo.new(3, EaseStyle), Gui.Viewport, {
|
||||
Position = UDim2.fromScale(0.5, 2) --Guaranteed off screen
|
||||
})
|
||||
|
||||
FrameTween_Constructor:Start()
|
||||
local FrameTween = FrameTween_Constructor:Start()
|
||||
DeveloperTween_Constructor:Start()
|
||||
local ViewportTween = ViewportFrame_Constructor:Start() --The longest tween
|
||||
|
||||
--Text deleting effect
|
||||
task.spawn(function()
|
||||
local sandbox_text_len = #Gui.SandboxText.Text
|
||||
|
||||
for i = sandbox_text_len, 1, -1 do --"A sandbox experience" has the longest text
|
||||
local rhpid_text_len = #Gui.FrameworkText.Text
|
||||
|
||||
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,i-1)
|
||||
if rhpid_text_len ~= 0 then
|
||||
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,i-1)
|
||||
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)
|
||||
|
||||
ViewportTween.Completed:Wait()
|
||||
FrameTween.Completed:Wait()
|
||||
Stepped:Disconnect()
|
||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||
end
|
||||
|
||||
type GL_Cube = Instance
|
||||
type GL_Side = Instance
|
||||
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 Size = 300
|
||||
local WorldSize = 3
|
||||
|
||||
return function(IntroGui: ScreenGui, load_elapse_start: number)
|
||||
local Gui = GuiDependencies(IntroGui)
|
||||
|
||||
Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,5), Gui.GL_Cube.Position)
|
||||
local Stepped = RS.Stepped:Connect(function(Delta: number, dt: number)
|
||||
local ScreenD = workspace.CurrentCamera.ViewportSize
|
||||
local CenterX = ScreenD.X/2
|
||||
local CenterY = ScreenD.Y/1.4
|
||||
|
||||
local Cube_CF = Gui.GL_Cube.CFrame
|
||||
local Stepped = RS.Stepped:Connect(function(delta, dt)
|
||||
--Magic number heaven
|
||||
local d2 = delta*10
|
||||
Gui.FrameGradient.Rotation=d2
|
||||
Gui.ShadowGradient.Rotation=d2*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.GL_Cube.CFrame = Cube_CF*CFrame.Angles(math.rad(100*math.cos(delta/8)), 0, delta/2)
|
||||
Gui.Xframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_X.Distance, WorldSize)
|
||||
Gui.Xframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Xframe.Rotation = AXIS_R_3DScalar_X.Rotation
|
||||
|
||||
Gui.Xframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_X.Center.X, AXIS_R_3DScalar_X.Center.Y)
|
||||
Gui.Xframe_text.Rotation = Gui.Xframe.Rotation
|
||||
|
||||
Gui.Yframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Y.Distance, WorldSize)
|
||||
Gui.Yframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Yframe.Rotation = AXIS_R_3DScalar_Y.Rotation
|
||||
|
||||
Gui.Yframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Y.Center.X, AXIS_R_3DScalar_Y.Center.Y)
|
||||
Gui.Yframe_text.Rotation = Gui.Yframe.Rotation
|
||||
|
||||
Gui.Zframe.Size = UDim2.fromOffset(AXIS_R_3DScalar_Z.Distance, WorldSize)
|
||||
Gui.Zframe.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
Gui.Zframe.Rotation = AXIS_R_3DScalar_Z.Rotation
|
||||
|
||||
Gui.Zframe_text.Position = UDim2.fromOffset(AXIS_R_3DScalar_Z.Center.X, AXIS_R_3DScalar_Z.Center.Y)
|
||||
Gui.Zframe_text.Rotation = Gui.Zframe.Rotation
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
|
||||
Reference in New Issue
Block a user