Help implementing game logic from fish fillets

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
glitchapp
Party member
Posts: 235
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Help implementing game logic from fish fillets

Post by glitchapp »

Hello!, I love puzzles and specially sokoban based games and I'm attempting to implement the game mechanics of fish fillets with lua. I'm using already implemented mechanics of a normal sokoban game and trying to add the special mechanics on top of it. The rules I'm trying to implement are here: http://fillets.sourceforge.net/manual.php (I'm sure many of you already played or heard about the game)

and here is the code in github with what I accomplished so far (not much) https://github.com/glitchapp/Luasok

Any help or advice is welcome, there are many interesting problems that I want to solve and I have fun trying to implement it (at least till I can't move forward). The special mechanics of that game are for me very complex and I think help would be needed.

A brief description of the problems I need to solve just in case someone finds the challenge interesting:

1. The characters are two and they use more than one cell, I need to move them properly with all the cells involved.
2. Objects are made of (or use) more than one cell aswell and need to move all toguether.
3. Gravity, objects fall down and kills player on their path.
4. Objects can be supported and trasfered between the two players
5. Special steel objects that only the big character can move.

I may miss something but I think that is most of what's missing in top of the normal sokoban mechanics.
Attachments
luasok.love
(13.81 KiB) Downloaded 73 times
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help implementing game logic from fish fillets

Post by pgimeno »

I didn't know this game, even though it's in Debian. It reminds me a lot of Thunderbirds :) In fact, it looks like it picks ideas from Thunderbirds and Boulder Dash.

No wonder you're having trouble with it; the rules are quite complex. This is how I would approach this.

I'd use Tiled, having each object in a layer and using custom properties, but here's one possible approach without using Tiled. Here's the first level (based on a screenshot of Fillets-NG):

Code: Select all

return {
  { width = 29, layout =
      '               A             '
    ..'             ##A##           '
    ..'              #A#            '
    ..'              #A#            '
    ..' ####         #A#     ##   ##' 
    ..'#####     #####A#   #########'
    ..'###############A#############'
    ..'###############A#############'
    ..'###########     #############'
    ..'#######           ###########'
    ..'####                 ########'
    ..'###                    ######'
    ..'###                    ######'
    ..'###                     #####'
    ..'###                      ####'
    ..'###                        ##'
    ..'###                          '
    ..'###    a11.        ,222b     '
    ..'###    accc ddddddd2222b     '
    ..'####   aaaa  d   d  bbbb     '
    ..'#####  a  a  d   d  b  b  ###'
    ..'#######a  a  d   d  b  b ####'
    ..'#############################'
    ..'#############################'
    ..'#############################'
    ..'#############################'
  }, {
   ...
  }
}
When changing to a level, I'd preprocess it to separate the objects and the background, with each object in its own table. That's not something that you can do with your level data, because you can't distinguish each object from the others, especially if they are touching like in level 2 or 3.

This uses upper case letters for steel objects, and lower case letters for regular objects; each letter corresponds to a different object. The 1 and the point '.' correspond to the small fish, and the 2 and the comma ',' correspond to the big fish; the point and the comma are used to indicate look direction (these are only used for graphics, not for puzzle logic). The background is made only of spaces ' ' and hashes '#'.

In order to detect collisions, I'd copy the background to a new table, to which I'd draw objects, detecting, before being drawn, whether they collide with (i.e. whether they would overlap) something already drawn.

At the time of moving something, I'd take note of which objects can be moved without colliding. Then, with these objects in their new positions, try to move all the rest, and repeat until no object can move. Once you have the list of all objects that move by one tile, you can actually animate them on the screen, using their initial and final positions. This is necessary because when several stacked objects need to fall, only the bottommost can move at first, and once that one is moved, the next one can move, but in practice they should move all at the same time and not one at a time.

Hope that gives you a start. Please note that this is not the right forum for this kind of help; the Support and Development forum is better suited, as this one is basically for completed stuff, even if it's unfortunately being abused by some users as a development log.
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 »

Wow! Thanks for the answer, I did not expect such a detailed and extensive answer. I did not know that game but it looks really nice and smooth for spectrum, I like it, the graphics are also amazing for such a machine.

You are right, it is a complex task but I like the challenge, I will do my best and try to divide the task as you said, it sounds logical to me, basically dividing the complexity in layers. I think you are pointing in the right direction, my actual demo has the problem of being unable to distinguish the background and the characters so I think your idea is great.

I hope I can post news soon with some of the problems solved. Thank you very much! I find your answer very useful! regarding the thing on posting in the wrong section, it is my fault, I'm quite new here and I don't know yet much of how it works. Thanks again and I will post as soon as I move forward!
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 hope I don't make things worse, I opened a new post in the right section, I want to move this valuable post and answer there but it's not possible, I made a copy just in case it is lost. The new post is here: https://love2d.org/forums/viewtopic.php ... 13#p246313

I posted there a few things I started to do so please follow that post from now on.
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Fri Jan 28, 2022 8:55 am Hello!, I love puzzles and specially sokoban based games and I'm attempting to implement the game mechanics of fish fillets with lua. I'm using already implemented mechanics of a normal sokoban game and trying to add the special mechanics on top of it. The rules I'm trying to implement are here: http://fillets.sourceforge.net/manual.php (I'm sure many of you already played or heard about the game)
Not a game, but my try to make such simulation (blocks don't check other blocks; the agent cannot push two blocks):



https://github.com/darkfrei/love2d-lua- ... ush-blocks
Attachments
push-blocks-01.love
(2.11 KiB) Downloaded 68 times
: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 thanks! It looks definitively useful, I will check your code and see how can I implement it in my game I think it is exactly what I'm looking for, I just need to make the characters and objects move inside the grid and not smooth so that the puzzle work, but apart from that it is what I need. Thanks again!

I opened this post in the wrong section by mistake, please from now on use the right one, the link is here: https://love2d.org/forums/viewtopic.php ... 13#p246313
User avatar
darkfrei
Party member
Posts: 1168
Joined: Sat Feb 08, 2020 11:09 pm

Re: Help implementing game logic from fish fillets

Post by darkfrei »

glitchapp wrote: Sun Jan 30, 2022 7:33 am I opened this post in the wrong section by mistake, please from now on use the right one, the link is here: https://love2d.org/forums/viewtopic.php ... 13#p246313
You can ask to move your topic to the other forum's subsection.
: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 did, I hope I can solve this mess, sorry! :?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 13 guests