Page 1 of 1

Using Love's engine in different way

Posted: Thu Jan 17, 2013 9:27 am
by Garan
I've grown extremely appreciative of the graphics library that Love has. I was wondering if it were possible to use the engine with just the graphics library (and then just be able to call a graphics update when I need it without overcomplicated program flow). I feel rather limited by how it's structured (with the three different sectioned functions) and would rather be able to structure it in my own way.

Re: Using Love's engine in different way

Posted: Thu Jan 17, 2013 9:54 am
by Azhukar
Garan wrote:I've grown extremely appreciative of the graphics library that Love has. I was wondering if it were possible to use the engine with just the graphics library (and then just be able to call a graphics update when I need it without overcomplicated program flow). I feel rather limited by how it's structured (with the three different sectioned functions) and would rather be able to structure it in my own way.
Take a look at https://love2d.org/wiki/love.run , love.graphics.clear and love.graphics.present.

Use https://love2d.org/wiki/conf.lua to disable other modules.

Re: Using Love's engine in different way

Posted: Thu Jan 17, 2013 12:36 pm
by Lafolie
You can define your own love.run to easily achieve this. I'm not sure why you'd want to do that though, especially if you're using Löve for game development. The way it works right now is quite semantic and logical.

Could you share with us your ideal way that it should be handled? (e.g. your own love.run function)

Re: Using Love's engine in different way

Posted: Thu Jan 17, 2013 8:31 pm
by Garan
I am trying to make something turn-based. I figured that it would be much easier if I could control when I refresh the screen (this would also make things like menus easier to display). Also, can I alter love.draw to be able to be overloaded (or at least be called with another parameter)?

Re: Using Love's engine in different way

Posted: Thu Jan 17, 2013 9:55 pm
by Boolsheet
Keep in mind that you are at the mercy of the OS window manager if you don't redraw frequently. It's not a problem if the window stays on top of everything, but if another window temporarily obscures it, the window manager may assume that you're going to redraw the part that was covered. If you don't, it may contain garbage. Some operating systems push an event for this, but that's not exposed in LÖVE (or SDL). The behaviour is also different for every OS.

You can handle it properly by using a Canvas as your screen. You only have to clear and redraw the Canvas if there was a change, but can draw it to the screen continuously so the window stays updated.

There's no such thing as overloading in Lua (all functions are anonymous) but yes, if you use your own modified love.run, you can pass to love.draw whatever you want.