Help implementing game logic from fish fillets

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

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hello! First of all I'm very grateful for all the help received so far with this game. The game logic has been working perfectly... till now...
I found a strange bug that make a piece float in the air and not fall.

It is really strange because it only happens in one particular level and I can't find the reason.

The game logic is here: https://codeberg.org/glitchapp/fish-fil ... blocks.lua

The level is number 54 (any other level won't work in the attached demo). If the background become too dark when the engine is on please press the key "G".

Thanks for all the help so far!

Important update: I discovered that the bug with the "engine" piece only happens when the "key" is inserted in the engine.

Secondly, the bug with the pipe floating was my fault: I copied the same object twice and that was causing the bug, that problem is solved now.

The only remaining bug is the one with the engine with a "key" inserted which makes it float in the air.

I attached another gif with the engine without that key and it falls down properly.
Attachments
luasokdemo.love
Level 54, press "G" to change colors
(8.67 MiB) Downloaded 82 times
bugengine2.gif
bugengine2.gif (53.01 KiB) Viewed 2519 times
bugengine1.gif
bugengine1.gif (647.58 KiB) Viewed 2527 times
User avatar
darkfrei
Party member
Posts: 1173
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

Oh, yes, the problem of E-shaped blocks. Each of them can find the support and both cannot fall at all :)
It was solved for the pushing, but not for gravity, I need to reunderstand my code again and I probably can fix it.
Last edited by darkfrei on Thu Jul 07, 2022 9:21 am, edited 1 time in total.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

hei, don't worry it works on the rest of the 80 levels.
I'll be very happy if you find a solution!

Thank you darkfrei!
User avatar
darkfrei
Party member
Posts: 1173
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

I've fixed the other part:

(in /game/logic/push-blocks.lua)

Code: Select all

 -- new function:
function isValueInList (value, list)
	for i, v in ipairs (list) do if v == value then return true end end
end

-- fixed long IF for _each_ line:
function pb:drawOutline (block)
	local lines = block.lines
	local tileSize = self.gridSize
	local x, y = block.x-1, block.y-1
	local exceptions = {1, 2, 3, 4, 20, 28, 30, 31, 53, 54, 55, 56, 60}
	local exception = isValueInList (nLevel, exceptions) -- bool

	--do not draw Outlines if levels are:
	if objectscells=="yes" and not exception then
		for i, line in ipairs (lines) do
			love.graphics.line ((x+line[1])*tileSize, (y+line[2])*tileSize, (x+line[3])*tileSize, (y+line[4])*tileSize)
		end
	end
end
Actually, we can provide the exception flag as

Code: Select all

pb:drawOutline (block, noOutline)
or just skip this function by this exception :)

Code: Select all

-- other place:
if objectscells=="yes" and not exception then
	self:drawOutline (block)
end
Last edited by darkfrei on Fri Jul 08, 2022 5:19 am, edited 1 time in total.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Thanks Darkfrei, I already tested it and works perfectly, it will we uploaded on the next update.

I need to clean that spaghetti code little by little, I know how bad it is.

Thanks again for all the help!
User avatar
darkfrei
Party member
Posts: 1173
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

The main menu can be designed as list of spheres:

Code: Select all

local spheres = { -- don't forget local
  {level = 1, x = 9, y = 4, text = "first level"},
  {level = 1, x = 9, y = 5, text = "second level"},
}
And don't load the level on hovering of it (in level menu).
This demo-level-54 makes the errors that other levels trying to load sounds or images, but can't.

For my opinion, the information about level must be in the level, for example

Code: Select all

flags = {noOutline = true, palette = 4, texture = "level-54" }
Something complicated with the running engine and vibration, but we can have some custom drawing function for it.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

I agree with you, I'm currently syncing the audios but I will try to clean the code as soon as I can, I will implement what you wrote above.

Regarding the level menu, the levels are not loaded when on hover, only when you click on the numbers. The hovering only triggers the light on the number.

Code: Select all

if love.mouse.isDown(1) then
		if soundon==true then TEsound.play("externalassets/sounds/GUI_Sound_Effects/GUI_Sound_Effects_030.ogg","static") end
		love.timer.sleep( 0.5 )
		if y==2 and levelac1.open==true or y==3 and levelac2.open==true or y==4 and levelac3.open==true or y==5 and levelac4.open==true or y==6 and levelac5.open==true or y==7 and levelac6.open==true or y==8 and levelac7.open==true or y==9 and levelac8.open==true then
		nLevel=y-2 changelevel() gamestatus="game" end
		timer=0
		stepdone=0

		end
If you see the code above, it only loads when mouse is down.

The third thing you said about flags I find it very useful, the way I created parameters for every level is in the main.lua and I copied a fragment below.

Code: Select all

function assignfrgbck()

if nLevel==1 then  currentbck=level1bck   currentbck2=level1bck2 currentbck4=whale 			currentfrg=level1frg currentfrg2=level1frg2			scolor1={1,1,1,0.95} scolor2={1,1,1,0.8}  scolor3={1,1,1,1} expx=0.5 expy=0.5 bckx=0 bcky=0 bck2x=0 bck2y=0 frgx=0 frgy=0
Your advice is a lot more clean and I like it. Give me time because I have too much to do with syncing first and I will get into it and implement what you say.
User avatar
darkfrei
Party member
Posts: 1173
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Fri Jul 08, 2022 6:34 am Regarding the level menu, the levels are not loaded when on hover, only when you click on the numbers. The hovering only triggers the light on the number.
But I got this error :)
The some .ogg from other than 54 level is not loaded, also somehow I've got the error about the gamepad, that was be asked, but not available.

How to reproduce: open the last demo-level-54 (version 1 viewtopic.php?p=249356#p249356) and hover some buttons in the level menu, maybe resize the window.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hi, sorry I may not explained that I created that demo only to attach it here, I know it's mostly broken, I just wanted to keep it small 9mb.

The real game is currently 800mb and keeps getting bigger, it will probably reach 1gb soon, that's why I created the demo.

If you want to test the real game please download it from the repository, all the links are here: https://glitchapp.codeberg.page/

That demo will never be released outside of this forum, it is only created for developers.

Update: Sorry, now I understand what you mean, that's another bug I need help with:

Before, the resolution was changed by clicking a key in the keyboard and it worked well, since I added the option to the options menu something strange happens that keeps the mouse as down all the time (but only when you change resolution from the options menu). Not sure why that happens, any advice regarding that bug would be helpful.

Here is the code that causes the mouse to be like constantly pressed:

Code: Select all

local hovered = isButtonHovered (resol1kButton)
	drawButton (resol1kButton, hovered)
		if hovered and love.mouse.isDown(1) then 
			love.timer.sleep( 0.3 )
			res="1080p"
			--changeresolution()
			dividx=1 dividy=1 		love.window.setMode(1920, 1080, {resizable=true, borderless=false})
			love.timer.sleep( 1 )
		end
	
	local hovered = isButtonHovered (resol4kButton)
	drawButton (resol4kButton, hovered)
		if hovered and love.mouse.isDown(1) then 
			love.timer.sleep( 0.3 )
			res="4k"
			--changeresolution()
			dividx=0.468 dividy=0.468 love.window.setMode(3840, 2160, {resizable=true, borderless=false})
			love.timer.sleep( 1 )
		end
Thank you
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

Hi,

I want to show that the same problem with the game logic I reported above happens on another level.

!
columns.gif
columns.gif (120.4 KiB) Viewed 2208 times
It is hard to see so I added a screenshot to explain why the cube moves the stairs, the stairs have a block connected to the cube. That's how the puzzle is designed on that level. In both levels (23 and 54) the cube and the engine floats in the air.
Press "L" to exit to Level menu
Press "L" to exit to Level menu
buglevel23.png (57.23 KiB) Viewed 2208 times
I attached a demo so that anyone can test it, only level 23 and 54 works on this demo.

Thanks for all
Attachments
luasokdemo.love
(3.96 MiB) Downloaded 83 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 62 guests