New game file structure

Scratch making the framework/engine open source for now until i figure out a better file structure that will work with Rojo
This commit is contained in:
2023-12-19 18:00:36 -05:00
parent e95b377c4e
commit 3a84d5b85d
14 changed files with 281 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
local Camera = {
FOV = {
Default = 70,
Zoomed = 50
}
}
Camera.__index = Camera
function Camera.constructor(Player: Player)
return setmetatable({
Player = Player
}, Camera)
end
function Camera:LockFirstPerson()
self.Player.CameraMode = Enum.CameraMode.LockFirstPerson
end
return Camera

View File

@@ -0,0 +1,30 @@
local CoreGuis = {
IncludeReset = true --disable the reset button?
}
CoreGuis.__index = CoreGuis
local SG = game:GetService("StarterGui")
local function DisableReset(enabled: boolean)
--Roblox actually doesn't register this fast enough so we gotta resort to cringe tactics
repeat
local PossibleMemoryLeak = pcall(SG.SetCore, SG, "ResetButtonCallback", enabled)
task.wait()
until PossibleMemoryLeak
end
function CoreGuis:on()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
if CoreGuis.IncludeReset then
DisableReset(true)
end
end
function CoreGuis:off()
SG:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
if CoreGuis.IncludeReset then
DisableReset(false)
end
end
return CoreGuis

View File

@@ -0,0 +1,33 @@
local Crosshair = {
Icon = "rbxassetid://12643750723"
}
Crosshair.__index = Crosshair
--Use a custom crosshair so we can do effects to it
function Crosshair.constructor(Player: Player)
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.ResetOnSpawn = false
ScreenGui.Name = "Crosshair"
local CrosshairIcon = Instance.new("ImageLabel")
CrosshairIcon.AnchorPoint = Vector2.new(.5,.5)
CrosshairIcon.Position = UDim2.fromScale(.5,.5)
CrosshairIcon.Size = UDim2.fromScale(.4,.4)
CrosshairIcon.Image = Crosshair.Icon
CrosshairIcon.BackgroundTransparency = 1
CrosshairIcon.ScaleType = Enum.ScaleType.Fit
CrosshairIcon.Parent = ScreenGui
return setmetatable({
Player = Player,
ScreenGui = ScreenGui,
CrosshairIcon = CrosshairIcon
}, Crosshair)
end
function Crosshair:Spawn()
self.ScreenGui.Parent = self.Player:WaitForChild("PlayerGui")
end
return Crosshair

View File

@@ -0,0 +1,13 @@
local Mouse = {}
local UIS = game:GetService("UserInputService")
function Mouse:DisablePointer()
UIS.MouseIconEnabled = false
end
function Mouse:EnablePointer()
UIS.MouseIconEnabled = true
end
return Mouse

View File

@@ -0,0 +1,15 @@
local CoreGuis = require(script:WaitForChild("CoreGuis"))
local Mouse = require(script:WaitForChild("Mouse"))
local CameraSettings = require(script:WaitForChild("Camera"))
local Crosshair = require(script:WaitForChild("Crosshair"))
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Camera = CameraSettings.constructor(Player)
local CrosshairObject = Crosshair.constructor(Player)
CoreGuis:off()
Mouse:DisablePointer()
Camera:LockFirstPerson()
CrosshairObject:Spawn()