Help implementing game logic from fish fillets

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
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 »

Thanks glitchapp!

Yes, it will be nice for credits me.
Be sure that you call the pb:keypressed in the love.keypressed.
: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: Sun Feb 13, 2022 10:35 am Thanks glitchapp!

Yes, it will be nice for credits me.
Be sure that you call the pb:keypressed in the love.keypressed.
Done!

Press the key "6" to open the documentation tool, the first section is credits so you'll see it right away.

There is no other menu created yet so that's why I wrote the credits there, but of course once the main menu is done you will be there too!

Thank you very much, those game rules looked a lot easier than they actually were (at least for me). I think I would have never managed to make it work! It's amazing!

Now the work with the levels, graphics and menu can be started. I just need to set a flag to know when and where a level is done and also another to make sure just one fish can move certain objects.

Thank you! It's working!! :awesome:
Attachments
luasok.love
(628.15 KiB) Downloaded 140 times
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 »

Here are heavy blocks, that can be moved with heavy agents (both with cyan outline).

(tiles outline code:)

Code: Select all

local function setBlockOutline (block)
	local m = {} -- map of outlines
	local tiles = block.tiles -- list of tiles as {x1,y1, x2,y2, x3,y3 ...}
	for i = 1, #tiles, 2 do
		local x, y = tiles[i], tiles[i+1]
		if not m[y] then m[y] = {} end
		if not m[y][x] then 
			m[y][x] = {v=true, h=true} 
		else
			m[y][x].v = not m[y][x].v
			m[y][x].h = not m[y][x].h
		end
		
		if not m[y][x+1] then 
			m[y][x+1] = {v=true, h=false} 
		else
			m[y][x+1].v = not m[y][x+1].v
		end
		
		if not m[y+1] then m[y+1] = {} end
		if not m[y+1][x] then 
			m[y+1][x] = {v=false, h=true} 
		else
			m[y+1][x].h = not m[y+1][x].h
		end
	end
	local lines = {}
	for y, xs in pairs (m) do
		for x, tabl in pairs (xs) do
			if m[y][x].v then
				table.insert (lines, {x,y, x,y+1})
			end
			if m[y][x].h then
				table.insert (lines, {x,y, x+1,y})
			end
		end
	end
	block.lines = lines
end
2022-02-13T12_56_19-Untitled.png
2022-02-13T12_56_19-Untitled.png (64.45 KiB) Viewed 5488 times
Attachments
push-blocks-05.love
(4.79 KiB) Downloaded 137 times
Last edited by darkfrei on Sun Feb 13, 2022 12:40 pm, edited 1 time in total.
: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: Sun Feb 13, 2022 11:57 am Here are heavy blocks, that can be moved with heavy agents (both with cyan outline).

2022-02-13T12_56_19-Untitled.png
Yes!!! that was the last thing needed to be implemented! Amazing.

I don't mean to copy all the rules of the game, indeed the ports changed the rules, but one particular rule of the original game sets that the small fish not only can not push heavy objects, it dies instanlty if try to sustain one. but don't worry, I'm not even sure if that rule is ok because it makes the game too hard.

I will implement that last rule right now! thank you!

Done!

The small fish can not move the long steel bar anymore as it should be.

Incredible! I can wait to start doing levels, but I need a pause I think, working with game logic even If I just adapted it to my game has been to intense!

Thank you, I'm having fun now with this, let's see how far this game goes!

Small Update: the game is playable now with the second shader.

I did not develop the shaders, you can find the source here: https://www.shadertoy.com/view/tdlXDM
Attachments
luasok.love
(628.43 KiB) Downloaded 134 times
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help implementing game logic from fish fillets

Post by pgimeno »

glitchapp wrote: Sun Feb 13, 2022 12:05 pm I don't mean to copy all the rules of the game, indeed the ports changed the rules, but one particular rule of the original game sets that the small fish not only can not push heavy objects, it dies instanlty if try to sustain one. but don't worry, I'm not even sure if that rule is ok because it makes the game too hard.
No it doesn't. It makes the rules different, period. The level designer needs to take into account that rule while creating levels, that's all. It's still possible to make levels with increasing difficulty, no matter whether that's a rule or not. When I tell people about a Sokoban variation where you can not only push blocks but also pull them, people tend to go "Really? Doesn't that make the game too easy?" And the answer is no, it just changes the rules, making the levels designed for regular Sokoban not suitable for use with that variation. But it's still possible to design challenging levels with these rules. For example, this is a level designed for that variation:

Code: Select all

######
## .$#
##+# #
# +# #
#@+  #
##+  #
######
http://www.sokoban.cn/variant/PSokoban.png

This level is completely unsolvable with normal rules, but it's solvable (and challenging) with the variation that allows pulling boxes.

That said, I think that the level designers of Fish Fillets went too far with the difficulty. The learning ramp is very steep.

By the way, there are at least two other rules that aren't implemented. I'd advise to check the first three levels of Fish Fillets NG for a full walkthrough of the rules, because there are at least two that aren't working like in the game: pushing blocks when fitting exactly in the object (imagine a U-shaped object where the fish fits exactly) should be allowed, but it isn't; and when moving a piece that is resting on a fish, and doesn't become supported by something after moving it, the fish dies.

Here are the first three levels:

Code: Select all

local levels = {
 { width = 29, layout = [[
...............A.............
.............##A##...........
..............#A#............
..............#A#............
.####.........#A#.....##...##
#####.....#####A#...#########
###############A#############
###############A#############
###########.....#############
#######...........###########
####.................########
###....................######
###....................######
###.....................#####
###......................####
###........................##
###.........................!
###....a111........4444b....!
###....accc.ddddddd4444b....!
####...aaaa..d...d..bbbb....!
#####..a..a..d...d..b..b..###
#######a..a..d...d..b..b.####
#############################
#############################
#############################
#############################
]]}, { width = 48, layout = [[
.####...........................................
..######........#######.........................
...#####################.....###.......##.......
#....#############################..#######.....
#.111.#######################################...
#.............#####......####..###############..
##.2222.........##...............###############
###2222...aaaaaaaa...............###############
###.......aaaaaaaa....................##########
####......aaaaaaaa.....................#########
#################.......................########
#################.......................########
#################........................#######
####.....########........................#######
##.......####################.............######
#...........b..#############..............######
#..........bb...############...##.........######
#..........bb...############...####.......######
#..........##...####...#ccc#A..####.......######
##...............#......ccc.A.####........######
#####............#......ccc.A..###........######
##...............#......ccc.A..##.........######
#.......................ccc.A.............######
#....e...................d..AA...........#######
#....eeee................####............#######
##...e...................####...........########
######.......BB..........######........#########
##.........fffff.........########....###########
#..........ff....#.......#######################
#..........fffff##....##.#######################
#............#####....##########################
#...............##....##########################
##...............#.....###################.....!
##...............#........#############........!
####...........####............................!
####################........................####
################################################
]]}, { width = 40, layout = [[
########################################
########################################
############......A......######.....####
#########.#.......A.......#...........##
########........#####..................#
######.............##..........###.....#
#####..................................#
######.......#...#########............##
#######......##.###########.aaa......###
########......#.#....########........###
###..###.............####...........####
##....b##............#..............####
##....b########.#....##.......B......###
##....b.#########....####..BBBBBBBBB.###
##....b.########.....#####......##...###
##....b...####........##........########
#.....b...............##..........######
#.....b...............###...........####
#.....b..............####............###
#.....##################.............###
#.....................C#.............###
!.....................c............#####
!.....................########....######
###.#########################......#####
##.......#ddddd........######ee.......##
##.........D..d..........####ee........#
#..........D..............###ee........#
#....f.....##...............#gg........#
#...hh...####.#..............gg........#
#.iiiii..######.......jj.....gg........#
#.111....#######......jj...####........#
#....4444##########...jj..#####.......##
#####4444######################......###
################################...#####
########################################
]]}
Note in the third level how the C piece (upper case, so heavy) is going to fall on the small fish and crush it, as soon as the fish pushes the c piece (lower case, so normal). Those are basically equivalent to a wall, because the small fish is the only one that fits through the hole but can't cross it.
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 »

pgimeno wrote: Sun Feb 13, 2022 2:38 pm
glitchapp wrote: Sun Feb 13, 2022 12:05 pm I don't mean to copy all the rules of the game, indeed the ports changed the rules, but one particular rule of the original game sets that the small fish not only can not push heavy objects, it dies instanlty if try to sustain one. but don't worry, I'm not even sure if that rule is ok because it makes the game too hard.
No it doesn't. It makes the rules different, period. The level designer needs to take into account that rule while creating levels, that's all. It's still possible to make levels with increasing difficulty, no matter whether that's a rule or not. When I tell people about a Sokoban variation where you can not only push blocks but also pull them, people tend to go "Really? Doesn't that make the game too easy?" And the answer is no, it just changes the rules, making the levels designed for regular Sokoban not suitable for use with that variation. But it's still possible to design challenging levels with these rules. For example, this is a level designed for that variation:

Code: Select all

######
## .$#
##+# #
# +# #
#@+  #
##+  #
######
http://www.sokoban.cn/variant/PSokoban.png

This level is completely unsolvable with normal rules, but it's solvable (and challenging) with the variation that allows pulling boxes.

That said, I think that the level designers of Fish Fillets went too far with the difficulty. The learning ramp is very steep.

By the way, there are at least two other rules that aren't implemented. I'd advise to check the first three levels of Fish Fillets NG for a full walkthrough of the rules, because there are at least two that aren't working like in the game: pushing blocks when fitting exactly in the object (imagine a U-shaped object where the fish fits exactly) should be allowed, but it isn't; and when moving a piece that is resting on a fish, and doesn't become supported by something after moving it, the fish dies.

Here are the first three levels:

Code: Select all

local levels = {
 { width = 29, layout = [[
...............A.............
.............##A##...........
..............#A#............
..............#A#............
.####.........#A#.....##...##
#####.....#####A#...#########
###############A#############
###############A#############
###########.....#############
#######...........###########
####.................########
###....................######
###....................######
###.....................#####
###......................####
###........................##
###.........................!
###....a111........4444b....!
###....accc.ddddddd4444b....!
####...aaaa..d...d..bbbb....!
#####..a..a..d...d..b..b..###
#######a..a..d...d..b..b.####
#############################
#############################
#############################
#############################
]]}, { width = 48, layout = [[
.####...........................................
..######........#######.........................
...#####################.....###.......##.......
#....#############################..#######.....
#.111.#######################################...
#.............#####......####..###############..
##.2222.........##...............###############
###2222...aaaaaaaa...............###############
###.......aaaaaaaa....................##########
####......aaaaaaaa.....................#########
#################.......................########
#################.......................########
#################........................#######
####.....########........................#######
##.......####################.............######
#...........b..#############..............######
#..........bb...############...##.........######
#..........bb...############...####.......######
#..........##...####...#ccc#A..####.......######
##...............#......ccc.A.####........######
#####............#......ccc.A..###........######
##...............#......ccc.A..##.........######
#.......................ccc.A.............######
#....e...................d..AA...........#######
#....eeee................####............#######
##...e...................####...........########
######.......BB..........######........#########
##.........fffff.........########....###########
#..........ff....#.......#######################
#..........fffff##....##.#######################
#............#####....##########################
#...............##....##########################
##...............#.....###################.....!
##...............#........#############........!
####...........####............................!
####################........................####
################################################
]]}, { width = 40, layout = [[
########################################
########################################
############......A......######.....####
#########.#.......A.......#...........##
########........#####..................#
######.............##..........###.....#
#####..................................#
######.......#...#########............##
#######......##.###########.aaa......###
########......#.#....########........###
###..###.............####...........####
##....b##............#..............####
##....b########.#....##.......B......###
##....b.#########....####..BBBBBBBBB.###
##....b.########.....#####......##...###
##....b...####........##........########
#.....b...............##..........######
#.....b...............###...........####
#.....b..............####............###
#.....##################.............###
#.....................C#.............###
!.....................c............#####
!.....................########....######
###.#########################......#####
##.......#ddddd........######ee.......##
##.........D..d..........####ee........#
#..........D..............###ee........#
#....f.....##...............#gg........#
#...hh...####.#..............gg........#
#.iiiii..######.......jj.....gg........#
#.111....#######......jj...####........#
#....4444##########...jj..#####.......##
#####4444######################......###
################################...#####
########################################
]]}
Note in the third level how the C piece (upper case, so heavy) is going to fall on the small fish and crush it, as soon as the fish pushes the c piece (lower case, so normal). Those are basically equivalent to a wall, because the small fish is the only one that fits through the hole but can't cross it.
I'm happy to tell you that I've just tested the first rule you mention and it works. I added a C like object, please test it by yourself, I attached the game with the new piece. Fit the small fish inside and lift it and push it. It works!

With the second rule you are totally right, you can push and slide objects in top of the other fish without killing it, but as you said that rule just make level design different. I'm not upset (how could I?) that the rule is not there, the game is playable and I'm happy with that.

To me the most important piece missing now is the function that tells that the level is finished and load the next one. I started doing a pair of functions let's see if I manage to do it, I still don't understand how functions returns true or false I hope I learn this time for good and manage to do it.

I started creating two simple functions that I will add to the game logic which will be in charge of checking if the level is solved and loading the next one if returns true.

Code: Select all

function exit()
	if self.agent.x >= 26 then
		next_level()
	end
end

function next_level()
current_level=current_level+1
local level = require ('game/levels/level-'..current_level)
end
This is just a preliminary idea, I still have to test it. I leave it here just in case someone have a better one.
Attachments
luasok.love
(629.67 KiB) Downloaded 150 times
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help implementing game logic from fish fillets

Post by pgimeno »

Hmm, in darkfrei's demo I could not move the U shaped piece with the big fish from the inside. There's something fishy (excuse the pun).
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 »

pgimeno wrote: Sun Feb 13, 2022 3:12 pm Hmm, in darkfrei's demo I could not move the U shaped piece with the big fish from the inside. There's something fishy (excuse the pun).
Haha absolutely, I don't know which one of the demos you tested, he already did 5 versions I think the last one (number 5) contains all the new functions and implementations.

Just to make sure I did a bigger C to fit the big fish and it also works!
test.gif
test.gif (25.51 KiB) Viewed 5444 times
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 »

Yes, here was an issue that the block cannot be moved if it (after moving) collides with the agent. Added the exception for active agent.

Maybe some issue with two E-shaped blocks, but I think that the list of moving blocks solve this problem.

Update:
Easy levels, how to call it and how to switch (press any key to start the next one) them:
levels-01.love
(2.22 KiB) Downloaded 147 times
Update 2: graphics
2022-02-13T23_21_07-Untitled.png
2022-02-13T23_21_07-Untitled.png (79.05 KiB) Viewed 5405 times
Attachments
push-blocks-06.love
(56.7 KiB) Downloaded 169 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: Sun Feb 13, 2022 4:45 pm Yes, here was an issue that the block cannot be moved if it (after moving) collides with the agent. Added the exception for active agent.

Maybe some issue with two E-shaped blocks, but I think that the list of moving blocks solve this problem.

Update:
Easy levels, how to call it and how to switch (press any key to start the next one) them:
levels-01.love

Update 2: graphics
2022-02-13T23_21_07-Untitled.png
darkfrei wrote: Sun Feb 13, 2022 4:45 pm Yes, here was an issue that the block cannot be moved if it (after moving) collides with the agent. Added the exception for active agent.

Maybe some issue with two E-shaped blocks, but I think that the list of moving blocks solve this problem.

Update:
Easy levels, how to call it and how to switch (press any key to start the next one) them:
levels-01.love

Update 2: graphics
2022-02-13T23_21_07-Untitled.png
Haha, man you are making me laugh, you even made graphics! This is awesome! I will implement it as soon as possible.

I have a little brainstorm now that everything is working and I would like to make a little survey.

now that everything that's crucial for the gameplay is working I ask myself the question: what's next?

I have some ideas I would like to implement, the good news is whether I manage to implement it or not, it does not matter because the game is fully playable, so things can be taken calmly and take all the time needed to do it.

First let me explain what tools have been included and can be actually used to build content:

Moonshine libraries:

Chainable post processing shaders for love. The cool crt effect used in the game is created with this library.

Shadertoy shaders renderer.

This is a another gem found on this forum, you can find the post to this file here: https://love2d.org/forums/viewtopic.php ... oy#p234276

Tip: You can combine both moonshine and shadertoy shaders simultaneously, the results are amazing! You can test it in the game already!

Slab: https://github.com/flamendless/Slab
An Immediate mode Gui for the Love2d framework. This is the library with which the documentation tool I created is built: https://github.com/glitchapp/luamilestones

Talkies: A dialog system for Löve2d. A rewrite of Moan.lua.
I started a small tutorial with this library (press "T" to start it) but not only tutorials can be made with this. I story that enhance the gameplay can be created with this tool.

Groverburger's 3D engine (ged) Simple and easy 3d Engine for Löve

This library is not yet used in the game but I started experimenting with it. I'm not sure how I will use and which graphics will use it (if backgrounds, maps, objects). I will see, but it looks like a nice library to make something special. I actually experimented with 3d graphics, check the Vr port: https://github.com/glitchapp/luasokvr. I want to mention that Vr is a lot more performance hungry for the simple reason that everything needs to be rendered twice so performance optimization are very needed to make the game accessible on normal computers.

LV-100 https://github.com/Eiyeron/LV-100 A love2d library to make terminal-like-stuff
This is a nice library I use to show information or request input from the user. It make a nice use of shaders to present everything like in a old terminal like system.

This is basically all what's done and included till now apart of the game logic that is already finished.

Now coming back to the question of what's next?

Here there are a few ideas I have, they don't need to be implemented, they are just ideas to improve the game. I'll be happy to know what you think of them.

1. Documenting / publishing development progress and ideas.

I started doing efforts on that with the goal and hope that it will help people get involved and interested. I decided to create my documentation tool (https://github.com/glitchapp/luamilestones) made with slab. The first question I have is,
Should I keep documenting the development progress inside the tool or should I build an external website for it? (both things are possible)

If I choose to keep using the documentation tool the update feature needs to be finished. There are two important reasons for that: first content can't be outdated, otherwise it makes the tool useless, secondly, I commit myself to keep the game as small as possible, so all pictures and heavy content need to be downloaded from outside. There's no need to say that slab is very limited in comparison to what it can be achieved with a real website.

If I choose the second, how should I build it. I've been testing some static website generators (pelican) and checking some themes. What would you recommend?

2. Level editor.
I always have a dilemma when I decide to include external libraries: Is the task complex enough that it does not worth doing it from scratch? I think a level editor is. Using external libraries are mostly the best option but they also carry negative sides: Those libraries are not as flexible as you may wish and sometimes part of them are not as accessible as if you did all from scratch.
Straight to the question? Which library would you recommend in case I decide to integrate a level editor inside the game?

3. Arm ports.
Love supports arm (really??) Yes. but making the game compatible with android or raspberry is not as trivial as you may actually think. The most important challenge when making ports that are pleasantly playable on those devices are to me 3:

3.1. Most arm devices does not have buttons (really??) Yes, so touch controls need to be created. Fortunately that it's not new to me, I already made a sokoban port for android with touch controls: https://github.com/glitchapp/GlitchSokoban/releases . Keep this in mind if you want to contribute with graphics.

3.2. Compatibility: love works on arm but not all shaders work on android. The solution to this problem is super easy: all incompatible shaders needs to be disabled.

3.3. Performance. Even if the shaders works (I tested on raspberry pi some of the shaders and they work) the performance could be so miserable that it may make the device crash or make the game unplayable. If optimization is not possible or too much work, the easiest solution is to disable the GPU hungry shaders.

3.4. I don't want to leave this outside, playing on small screens makes sometimes a huge different, Fortunately I already implemented a few features specially for android to solve the limitations of small screens on my last sokoban port to android: camera follows player, zoom adapted to the level size and screen size.

4. Game map and main menu needs to be implemented, I did a menu before with menu engine https://github.com/Astorek86/love2d-menuengine. What library would you recommend to create the game menu?

5. Graphics, style and design. I'm not a graphic artist and there are thousands ways and styles to make designs for a game. I just wish all the styles are coherent and I leave this open for you to let me know.

I think once some of those tools / decisions are made mane new questions will arise: should the old levels be recreated or should we create new ones...

I feel and I hope this game as a long way and can get mature and be something special. I leave this brainstorm here and I'll be happy to know about your ideas.

In the meanwhile I will finish implementing the last update from darkfrei, it's amazing that the whole game logic it's working!
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests