Page 1 of 1

hump gamestate and push library?

Posted: Sat Mar 09, 2024 2:53 am
by adjcodes
Has anyone tried using hump's gamestate and push together?

I'm getting some weird results when trying to use love.resize() and calling push:resize(). When I maximise the window, text I render in the gamestate's draw function shifts from left aligned to indented. I think it's because I need to use push:start() and push:finish() in both the gamestate's draw method and in the love.draw() and they do something weird when used together.

If I remove Gamestate.registerEvents() in love.load() and manually call the Gamestate like

function love.draw()
push:start()
Gamestate:current().draw()
Debug.draw()
push:end()
end

Then everything resizes correctly.

Re: hump gamestate and push library?

Posted: Sat Mar 09, 2024 9:39 pm
by Azzla
I think it's because I need to use push:start() and push:finish() in both the gamestate's draw method and in the love.draw() and they do something weird when used together.
You've already identified the problem and the solution -- don't call those functions in both places. I don't know what they are doing but it looks like some pushing/popping draw calls to/from a stack. You almost certainly don't need to do that from love's global callbacks. As soon as you invoke registerEvents() and swap to a gamestate, you don't need to touch love's anymore. If you feel like you do, then please share a .love archive or some of the code involved.

Side note, I recommend using roomy instead of hump gamestate. Gamestate has some bugs that have never been resolved and roomy is simpler but functionally identical anyway.

Re: hump gamestate and push library?

Posted: Mon Mar 11, 2024 1:03 am
by adjcodes
Thanks for the suggestion for roomy, I'll check it out. One of the things I'm struggling with at the moment as someone new to Love2D, is just how many libraries there are out there that tackle the same thing. I don't want to reinvent the wheel if there are existing commonly used libraries out there that do what I want, but as most libraries are many years old and may not be maintained any more, it's taking some time to work out which ones work, and which work well with others.

Re: hump gamestate and push library?

Posted: Tue Mar 12, 2024 10:17 pm
by Azzla
adjcodes wrote: Mon Mar 11, 2024 1:03 am Thanks for the suggestion for roomy, I'll check it out. One of the things I'm struggling with at the moment as someone new to Love2D, is just how many libraries there are out there that tackle the same thing. I don't want to reinvent the wheel if there are existing commonly used libraries out there that do what I want, but as most libraries are many years old and may not be maintained any more, it's taking some time to work out which ones work, and which work well with others.
Can't argue with you there (everyone starts with the hump libs), but on the other hand, it speaks to the great community that there is probably a library for whatever feature you need! Just be careful not to depend too heavily on the code of others; you'll get a lot of valuable experience from writing your own systems.

In the beginning it is overwhelming to code everything yourself, but once you're a little more practiced with the framework you will find its flexibility and mobility addictive. I can whip up a prototype for a game jam way faster with Love than I can with engines like Unity or Godot. :nyu: