Page 1 of 2

Questions about platform game development

Posted: Sat Feb 11, 2012 8:40 am
by molul
Ok, my platform game is on its way. Currently I've managed to have an animated character with basic movement (walking and jumping) in a tiled background plus a five layer parallax scroll. I'm detecting collision to the ground in a very primitive way, and my next step is to properly detect ground and walls (once I get to this I'd like to share with you what I'm into, although it's on a very early stage).

At first I was planning to use löve2d's physics module, but I've been told to use the hardOnCollider instead, and I've some doubts: does it process gravity for all the characters in the game (as love.physics has its "world" and "body" objects), or should I implement it for each character?

On the other hand, the friend that told me about Löve2D told me yesterday that he thinks it should be possible to reload all the lua files while running the program. Is it really possible? It would be really convenient indeed.

Also it would be nice having a "console inside" while running the game, so you can change any variable to debug faster. Is it possible as well?

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 8:56 am
by nevon
molul wrote:On the other hand, the friend that told me about Löve2D told me yesterday that he thinks it should be possible to reload all the lua files while running the program. Is it really possible? It would be really convenient indeed.
Not sure if I understand what you mean, but if you change the reference to nil, the garbage collector will take care of unloading stuff. To load a file, you just use require.
molul wrote:Also it would be nice having a "console inside" while running the game, so you can change any variable to debug faster. Is it possible as well?
You can use debug.debug(), if you launch the game from a terminal. Example (the code may not be entirely correct, as I haven't written any lua for 6 months):

Code: Select all

function love.keyboard(key)
    if (key=='rctrl') then
        debug.debug()
    end
end

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 11:05 am
by bartbes
nevon wrote:

Code: Select all

function love.keypressed(key)
    if key == 'rctrl' then
        debug.debug()
    end
end
FIFY

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 3:00 pm
by molul
Thanks for the debug thing :) I'll try it.
nevon wrote:
molul wrote:On the other hand, the friend that told me about Löve2D told me yesterday that he thinks it should be possible to reload all the lua files while running the program. Is it really possible? It would be really convenient indeed.
Not sure if I understand what you mean, but if you change the reference to nil, the garbage collector will take care of unloading stuff. To load a file, you just use require.
Yes sorry, I didn't ellaborate much. This is, ideally, what I'd like to do:

-I run my game.
-With the game running, I change the code.
-Back in the game window, I press a key and then the game is reset with the new code.

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 3:07 pm
by nevon
molul wrote:Thanks for the debug thing :) I'll try it.
nevon wrote:
molul wrote:On the other hand, the friend that told me about Löve2D told me yesterday that he thinks it should be possible to reload all the lua files while running the program. Is it really possible? It would be really convenient indeed.
Not sure if I understand what you mean, but if you change the reference to nil, the garbage collector will take care of unloading stuff. To load a file, you just use require.
Yes sorry, I didn't ellaborate much. This is, ideally, what I'd like to do:

-I run my game.
-With the game running, I change the code.
-Back in the game window, I press a key and then the game is reset with the new code.
If you're intializing the game properly in love.load, you could just bind that to a key.

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 3:10 pm
by Robin
If your libraries are written right, something like this should work:

Code: Select all

function love.keypressed(key)
    if key == 'f5' then
        love.filesystem.load("something.lua")()
    end
end
You can also use "require", but then you must remember to set package.loaded[modulename] to nil.

The most complete answer is: it depends.

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 3:47 pm
by molul
Thanks Robin, that worked perfectly. I love this community :) The debug thing I'll try it later, as currently I don't have my project set up to be run from terminal.

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 11:04 pm
by tentus
Its actually not that hard to write a mini command prompt inside your game, using loadstring()(). The hardest part is adding miscellaneous little features, like previous command.

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 11:41 pm
by molul
Interesting. I'll try to implement it in the future. For now I want to get into HardOnCollider.

By the way, tentus, I remember you told me to use it instead of love.physics module. Could you please tell me some good reasons (mostly to tell my partners)? RIght now I know very few of both, and I'd like to have some information before I choose one or the other. Thanks beforehand!

Re: Questions about platform game development

Posted: Sat Feb 11, 2012 11:43 pm
by bartbes
Well, love.physics is more suited for realistic physics, which is generally what platform games don't want to have. (A common complaint is it all feeling to "floaty".)