Help implementing game logic from fish fillets

General discussion about LÖVE, Lua, game development, puns, and unicorns.
glitchapp
Party member
Posts: 237
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Amazing darkfrei! thanks again for the help.

I think I just need to add some of the values of the grid size and windows size but that's exactly the function I need, it is simply an equation but I never created a function to solve it.

Thanks, I will let you know once the problem is solved!
User avatar
darkfrei
Party member
Posts: 1181
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Sat Sep 09, 2023 11:24 am Amazing darkfrei! thanks again for the help.

I think I just need to add some of the values of the grid size and windows size but that's exactly the function I need, it is simply an equation but I never created a function to solve it.

Thanks, I will let you know once the problem is solved!
Normally I solve this problem with excel, it can give the formula by the linear or polynomial trend:
https://www.youtube.com/watch?v=PRlfb8npppU

But it was interesting to make the easy version of it with Lua.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 237
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

sure I need time to test but now the solution is really close, I just need to make sure that the provided parameters return the desired values for every given resolution and maze size, I can't test this now but I will do it later, I will probably use xcell which is faster first and then pass the parameters inside the code.

Once this problem is solved all major problems are solved... there are some issues with specific shaders and menus but nothing critical.

Thanks!
User avatar
darkfrei
Party member
Posts: 1181
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

Rounded and simplified inputs, rounded output:

Code: Select all

print ('1:')
local cs1 = calculateQuadraticPolynomialCoefficients(720/1080, 0.375, 1080/1080, 0.5, 1440/1080, 2/3)
print("a1 =", cs1[1])
print("b1 =", cs1[2])
print("c1 =", cs1[3])

print ('x	y1')
local a, b, c = cs1[1], cs1[2], cs1[3]
for i = 1, 6 do
	local h = 360*i/1080
	local y1 = a*h^2 + b*h + c 
	print (h*1080, y1)
end

-- returns:
--a1 =	0.1875
--b1 =	0.0625
--c1 =	0.25
--x	y1
--360.0	0.29166666666667
--720.0	0.375
--1080.0	0.5
--1440.0	0.66666666666667
--1800.0	0.875
--2160.0	1.125

print ('2:')
local cs2 = calculateQuadraticPolynomialCoefficients(720/1080, 0.75, 1080/1080, 1.0, 1440/1080, 4/3)
print("a2 =", cs2[1])
print("b2 =", cs2[2])
print("c2 =", cs2[3])

print ('x	y2')
local a, b, c = cs2[1], cs2[2], cs2[3]
for i = 1, 6 do
	local h = 360*i/1080
	local y1 = a*h^2 + b*h + c 
	print (h*1080, y1)
end

-- returns:
--a2 =	0.375
--b2 =	0.125
--c2 =	0.5
--x	y2
--360.0	0.58333333333333
--720.0	0.75
--1080.0	1.0
--1440.0	1.3333333333333
--1800.0	1.75
--2160.0	2.25
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 71 guests