Help implementing game logic from fish fillets

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
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
I implemented everything in my game with all the tools, it works but there are a pair of bugs that do not react like in your code:

1. Graphics are not loaded, I just set up a different folder but even keeping the same structure they don't load...

Code: Select all

local path = 'assets/players'
2 Problem when pressing enter instead of restarting the level everything moves to the left. Is that happening because I changed the path?

Update:

Code: Select all

local path = 'assets/players/'
Sorry I'm so stupid, a "/" at the end was missing that's all with the graphics.

The other bug still remain, and the reason must be here:

Code: Select all

	pb:keypressedMoving (scancode)
	if key == 'space' then
		pb:switchAgent ()
	elseif key == 'return' then
		package.loaded['levels.level-1'] = nil
		level = require ('game/levels.level-1')
		pb:load (level)
	elseif key == "escape" then
		love.event.quit()
	end
I can't understand what's wrong, maybe that the levels are in a different folder?
Attachments
luasok.love
(609.75 KiB) Downloaded 98 times
Last edited by glitchapp on Wed Feb 16, 2022 6:49 am, edited 1 time in total.
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 »

require ('game/levels.level-1')
Must be
require ('game.levels.level-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: Mon Feb 14, 2022 7:17 am require ('game/levels.level-1')
Must be
require ('game.levels.level-1')
done, still not working, I tested all of this combinations:

Code: Select all

		package.loaded['levels.level-1'] = nil
		level = require ('game.levels.level-1')
		
		package.loaded['level-1'] = nil
		level = require ('game.levels.level-1')
		
		package.loaded['level-1'] = nil
		level = require ('levels.level-1')
		
		package.loaded['game.levels.level-1'] = nil
		level = require ('game.levels.level-1')
none of them work...

Sorry I know what's happening, the level was already loaded first and overrides your code. Solved. I will update it soon.

Updated!

Nothing personal against your selection of colors, but the fish like more mines so I override them (look how happy they are). It's not me it's them, I hope you don't disagree with them.
sc1.png
sc1.png (96.56 KiB) Viewed 5118 times
:)
Attachments
luasok.love
(610.22 KiB) Downloaded 106 times
Last edited by glitchapp on Mon Feb 14, 2022 8:36 am, edited 3 times in total.
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 »

See the code of levels-01.love here: https://love2d.org/forums/viewtopic.php ... 57#p246657

We can load all levels:

Code: Select all

levels = {}
for i = 1, 6 do
	local filename = 'levels/level-'..i..'.lua'
	local info = love.filesystem.getInfo (filename)
	if info then
		local level = love.filesystem.load (filename)
		table.insert (levels, level)
	end
end
open and execute code from this level:

Code: Select all

function loadLevel ()
	if not levels[nLevel] then
		nLevel = 1
	end
	level = levels[nLevel]() -- brackets are execution
end
So just set the number of level and load it:

Code: Select all

function love.load()
	nLevel = 1
	loadLevel ()
end
On level is done, press any key to load the next level:

Code: Select all

function love.keypressed(key, scancode, isrepeat)
	if level.done then
		nLevel = nLevel + 1
		loadLevel ()
	end
end
: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: Mon Feb 14, 2022 8:11 am See the code of levels-01.love here: https://love2d.org/forums/viewtopic.php ... 57#p246657

We can load all levels:

Code: Select all

levels = {}
for i = 1, 6 do
	local filename = 'levels/level-'..i..'.lua'
	local info = love.filesystem.getInfo (filename)
	if info then
		local level = love.filesystem.load (filename)
		table.insert (levels, level)
	end
end
open and execute code from this level:

Code: Select all

function loadLevel ()
	if not levels[nLevel] then
		nLevel = 1
	end
	level = levels[nLevel]() -- brackets are execution
end
So just set the number of level and load it:

Code: Select all

function love.load()
	nLevel = 1
	loadLevel ()
end
On level is done, press any key to load the next level:

Code: Select all

function love.keypressed(key, scancode, isrepeat)
	if level.done then
		nLevel = nLevel + 1
		loadLevel ()
	end
end
I override your colors:

Code: Select all

function love.keypressed(key, scancode, isrepeat)
if tedit=="no" then

	pb:keypressedMoving (scancode)
	if key == 'space' then
		pb:switchAgent ()
	elseif key == 'return' then
		package.loaded['game.levels.level-1'] = nil
		level = require ('game.levels.level-1')
		pb:load (level)

	love.graphics.setCanvas(canvas)
        love.graphics.clear()
                love.graphics.setColor(0.146, 0.73, 0.73)
		love.graphics.rectangle('fill', 000, 0,1920, 1080) -- the live code library changes the background, this is a temporary solution till I find the reason
		love.graphics.setColor(1,1,1)
		pb:drawMap ()
        
        --my personal colors
        loadwallborder()
        draw_level()
        draw_gamegui()
        draw_debug()
		pb:drawBackgroundGrid ()
        love.graphics.setCanvas()
		
	elseif key == "escape" then
		love.event.quit()
	end
I will implement that for the next update, I don't think uploading the game over and over for every small change it's ok, I keep it for the next big update and if I find any problem I will let you know ok?
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 project looks to big for me and I have no experience with any libs so I always write my own for better understanding how it works.
Yes, I've never done any project.

Your colors are better, but I think that we need textures for background, tiles and objects.
: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: Mon Feb 14, 2022 8:36 am The project looks to big for me and I have no experience with any libs so I always write my own for better understanding how it works.
Yes, I've never done any project.

Your colors are better, but I think that we need textures for background, tiles and objects.
Feel free to send me any graphic art you want, I may not always be online or send updates but I will be adding content as I receive it. By the way I just suppose you draw the fish yourself?

As you said this project can get very big so I have to find a way to make people aware and involved... I will think about making a website maybe... let's see ... there is time for all of that
User avatar
pgimeno
Party member
Posts: 3673
Joined: Sun Oct 18, 2015 2:58 pm

Re: Help implementing game logic from fish fillets

Post by pgimeno »

Code sharing sites (notabug, codeberg, github, gitlab, bitbucket...) are designed to solve precisely these kinds of problems.
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: Mon Feb 14, 2022 11:10 am Code sharing sites (notabug, codeberg, github, gitlab, bitbucket...) are designed to solve precisely these kinds of problems.
Thanks, that codeberg looks interesting, I did not know about it.

Yes you are right, it is just discussing more subjective topics like graphic styles or sharing art seems to me out of context on those places. I may consider opening a web page and email or forum to receive such kind of things like art / graphics etc that I think don't fit on those sites that are more oriented to code.
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 »

glitchapp wrote: Mon Feb 14, 2022 8:47 am By the way I just suppose you draw the fish yourself?
Yes, it's my graphics :) Used mouse, paint dot net and about 5 minutes time :)
The blue fish is just stretched up the gold one, than a little bit reworked.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests