Help implementing game logic from fish fillets

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

Re: Help implementing game logic from fish fillets

Post by glitchapp »

darkfrei wrote: Sun Jul 31, 2022 11:55 am
glitchapp wrote: Sun Jul 31, 2022 11:41 am The problems with the events has been solved and now the new push-block logic is used all the time and the old is deprecated.

Till now I can't find any bugs with the events so everything is alright.
Here can be (I haven't saw this issue) the problem by the falling blocks: it can be situation with "gluing" of blocks to metablocks and when some of blocks have contact with static element (map, block or fish), the other block will be not falling too, as glued to the first one. But I am not sure that it's possible and I cannot make this situation.

Maybe we can build the tetris with static and dynamic blocks to simulate it :)
I'm not sure what you mean by gluing, I guess it means that it takes some movement for the objects to complete the falling process. I think that caused some issues with the events triggered when falling and I solved it by applying a timer in the conditional. It works more or less now.

Regarding the tetris, there is already a tetris hidden in the full game which should be unlockable, here is a screenshot:
Tetris
Tetris
tetris.jpg (282.59 KiB) Viewed 7297 times
But I'm not using your game logic with that tetris, I'm using this code: https://simplegametutorials.github.io/love/blocks/

If you want to play with it and use your game logic you can do it, so that you can test those uncommon situations in which what you explain happens, I would probably understand better when I see it.

I can also create a level with the needed forms to test those situations.
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

This is an update to my last post: The game logic is completely working now including the exit area detection.
exit.jpg
exit.jpg (160.22 KiB) Viewed 7235 times
Thank you darkfrei!
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

Nice! Do you have some gameplay video?
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

No I dont, but it can be done easily, some assets are not finished so I did not make any trailer yet.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

The level looks impossible: (3 7 is a selected tile)
(press Num+ and Num- to go between levels)
2022-08-03T18_16_25-1. Ship Wrecks. Drowned Submarine.png
2022-08-03T18_16_25-1. Ship Wrecks. Drowned Submarine.png (30.3 KiB) Viewed 7102 times
Attachments
push-blocks.lua
(20.85 KiB) Downloaded 234 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

darkfrei wrote: Wed Aug 03, 2022 4:19 pm The level looks impossible: (3 7 is a selected tile)
(press Num+ and Num- to go between levels)
2022-08-03T18_16_25-1. Ship Wrecks. Drowned Submarine.png
Hi Darkfrei,

You are right, there's a mistake on that level, now the "exit" cells have the only purpose of not letting the players go outside the screen so that the game does not crashes, because the exit as you know is defined by the exit area instead of the exit cells, but in this level the small fish can not get out so the solution is to delete those exit cells, I will do it on the next update and the fish will be able to get out.
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

You can use this exit tiles as reference for exit areas, one cell is one area with w = 1 and h = 1 :)
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

darkfrei wrote: Wed Aug 03, 2022 5:36 pm You can use this exit tiles as reference for exit areas, one cell is one area with w = 1 and h = 1 :)
Sure, I need to polish and complete all the exit areas but it is a lot of repetitive boring work so it will take a little while.

There is also no save mechanism yet which is completely necessary for a game like this, I started something here but I'm not yet sure how I will do it: https://codeberg.org/glitchapp/fish-fil ... vegame.lua

It will probably save automatically and there will be profiles so that more than one player can play on the same game.
glitchapp
Party member
Posts: 264
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Help implementing game logic from fish fillets

Post by glitchapp »

I'm starting a function to save the progress of the game and to also store the achievements and options. The file is reduced just to give an example

Code: Select all

function loadmygame()
savedgame = love.filesystem.read("savedgames/save.txt")
end

function savemygame()

--achievements

--unlocked features
success, errormsg = love.filesystem.append( "savedgames/savedgame1.txt", leveleditorunlocked , all )
success, errormsg = love.filesystem.append( "savedgames/savedgame1.txt", extrasunlocked , all )
success, errormsg = love.filesystem.append( "savedgames/savedgame1.txt", musicplayerunlocked , all )

--unlocked levels
savedgame,savedgamemessage = love.filesystem.write("savedgames/savedgame1.txt",unlockedlevels,all)

	if success then 
		print ('file created')
	else 
		print ('file not created: '..savedgamemessage)
	end
end
I get the error Error: game/mainfunctions/savegame.lua:26: bad argument #2 to 'write' (string or Data expected). I''ve never worked with files in löve and I'm not sure what I'm doing wrong.

The variables I want to store are here: https://codeberg.org/glitchapp/fish-fil ... ements.lua

I need to add the game options too but once I get the above working that will not be a problem.

Why am I getting that error?

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

Re: Help implementing game logic from fish fillets

Post by darkfrei »

But you can convert exit cells to exit areas "on the fly":

Code: Select all

-- prepare exit areas
level.areas = {}
for y, xs in ipairs (level.map) do
	for x, value in ipairs (xs) do
		if value == 2 then
			-- exit cell to exit area
			table.insert (level.areas, {x=x, y=y, w=1, h=1, name = "exit"})
			-- remove exit cell
			level.map[y][x] = 0
		end
	end
end
2022-08-03T21_37_13-0.Fish House. Closed in the Closet.png
2022-08-03T21_37_13-0.Fish House. Closed in the Closet.png (33.23 KiB) Viewed 7047 times


:awesome:
You can save to file only text, so use some lib to write list/table into text and than save it.
And then read it: https://stackoverflow.com/questions/154 ... ble-in-lua
Attachments
level-8.lua
(3.73 KiB) Downloaded 222 times
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests