diff --git a/Test.lua b/Test.lua new file mode 100644 index 0000000..dddd2d3 --- /dev/null +++ b/Test.lua @@ -0,0 +1,8 @@ +local TweenService = game:GetService("TweenService") +local clock = os.clock +local first = clock() +for i = 1, 500 do + local alpha = TweenService:GetValue(20/6, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut) +end +local second = clock() +print(second-first) \ No newline at end of file diff --git a/src/client/EffectMaker.ts b/src/client/EffectMaker.ts index 629404e..9e81f83 100644 --- a/src/client/EffectMaker.ts +++ b/src/client/EffectMaker.ts @@ -1 +1,110 @@ -export function kablooey() {} +const TweenService = game.GetService("TweenService"); +type effectKeypoint = [number, Color3, Vector3, CFrame, number, Enum.EasingStyle?, Enum.EasingDirection?]; + +export function meshPartEffect( + effectFolder: Folder, + meshPart: MeshPart, + material: Enum.Material, + effectKeypoints: effectKeypoint[], +) { + const effectMeshPart = meshPart.Clone(); + effectMeshPart.Material = material; + + effectMeshPart.Color = effectKeypoints[0][1]; + effectMeshPart.Size = effectKeypoints[0][2]; + effectMeshPart.CFrame = effectKeypoints[0][3]; + effectMeshPart.Transparency = effectKeypoints[0][4]; + + effectMeshPart.CastShadow = false; + effectMeshPart.CanCollide = false; + effectMeshPart.Anchored = true; + effectMeshPart.Parent = effectFolder; + effectKeypoints.remove(0); + return [effectMeshPart, effectKeypoints, 0] as [MeshPart, effectKeypoint[], number]; + // Do the interpolation on one thread somehow +} + +function particleEffect() {} +/* +function getLerpKeypoint(time: number, pastKeypoint: effectKeypoint, futureKeypoint: effectKeypoint) { + let alpha = 0; + if (pastKeypoint[5]) { + alpha = TweenService.GetValue(time / futureKeypoint[0], pastKeypoint[5], Enum.EasingDirection.InOut); + } else { + alpha = time; + } + let new + for (let i = 1; i < 5; i += 1) { + + } +} +*/ + +function runEffects(timeSinceLastFrame: number, effectsToRun: [MeshPart, effectKeypoint[], number][]) { + for (const effect of effectsToRun) { + const meshPart = effect[0]; + const futureKeypoint = effect[1][1]; + const timeToNext = futureKeypoint[0]; + const timeSinceLastKeypoint = effect[2] + timeSinceLastFrame; + if (timeSinceLastKeypoint >= timeToNext) { + // Remove keypoint + // Set effect[3] to 0 + // Delete effect if no keypoints left + } else { + effect[2] = timeSinceLastKeypoint; + } + const pastKeypoint = effect[1][0]; + const easingStyle = pastKeypoint[5]; + // Get the alpha + let alpha = 0; + if (easingStyle) { + alpha = TweenService.GetValue( + timeSinceLastKeypoint / timeToNext, + easingStyle, + pastKeypoint[6] || Enum.EasingDirection.InOut, + ); + } else { + alpha = timeSinceLastKeypoint / timeToNext; + } + // Alter the effect + meshPart.Color = pastKeypoint[1].Lerp(futureKeypoint[1], alpha); + meshPart.Position = pastKeypoint[2].Lerp(futureKeypoint[2], alpha); + meshPart.CFrame = pastKeypoint[3].Lerp(futureKeypoint[3], alpha); + meshPart.Transparency = pastKeypoint[4] + (futureKeypoint[4] - pastKeypoint[4]) * alpha; + } +} +/* +local function horseEffModule(o,typ,a1,a2,a3,a4,a5,a6,a7) + return { + Color = a1, + Size = a2*typ[2], + ["CFrame"] = (type(a3) == "table" and o.CFrame*a3[1]) or a3, + Transparency = a4 + } +end + +--sequence entry format: +--{color,size,cframe,transparency,time to next,easingstyle,easingdirection} +--horseeffect "typ" takes a table with a meshpart as the first value and a scale vector3 as the second +local function horseEff(typ,material,sequence) --I understand if you don't use this function. Not everyone is cool enough. + wrap(function() + local o = typ[1]:Clone() + o.CastShadow = false + o.Anchored = true + o.CanCollide = false + o.Material = material + o.Color = sequence[1][1] + o.Size = sequence[1][2]*typ[2] + o.CFrame = sequence[1][3] + o.Transparency = sequence[1][4] + o.Parent = efFolder or workspace + for i = 2, #sequence do + local g = horseEffModule(o,typ,unpack(sequence[i])) -- goes and gets the information to be tweened to with less table indices + local tinfo = TweenInfo.new(sequence[i-1][5] or sequence[1][5],sequence[i-1][6] or sequence[1][6],sequence[i-1][7] or sequence[1][7]) + play(tweenServiceCreate(twS,o,tinfo,g)) + wait(sequence[i-1][5] or sequence[1][5]) + end + destroy(o) + end)() +end +*/ diff --git a/src/client/GuiHandler.ts b/src/client/GuiHandler.ts index d445df4..d2d98ab 100644 --- a/src/client/GuiHandler.ts +++ b/src/client/GuiHandler.ts @@ -97,7 +97,7 @@ const guiTable: guiTable = { Position: new UDim2(0.375, 0, 0.5, 0), Size: new UDim2(0.25, 0, 0.125, 0), Text: "Play", - onClick: [["MessageServer", "EnterGame"]], // The main menu should disappear in respone + onClick: [["MessageServer", "EnterGame"]], // The main menu should disappear in response }, { Type: "TextButton",