Page 3 of 4

Re: Platformer game engine (a proper one, really!)

Posted: Sun Apr 15, 2012 12:43 pm
by Ruirize
I've been tinkering this, and I'm struggling to work out how one would add friction into the engine.
Obviously, it would have to be framerate-independent, and so far, I can't seem to get a reliable consistent speed.

Anyone more math-oriented than me want to help?

Re: Platformer game engine (a proper one, really!)

Posted: Sun Apr 22, 2012 4:01 pm
by Lap
If you want to have anything framerate independent you are going to need to use the delta time (the dt in "love.update(dt)"). That will tell you the time between frames.

Re: Platformer game engine (a proper one, really!)

Posted: Mon May 14, 2012 1:51 am
by jspham
How do I use this engine, like source? I tried downloading that and opening the .love in notepad++ and get a string of odd/weird character

Re: Platformer game engine (a proper one, really!)

Posted: Mon May 14, 2012 3:19 am
by coffee
jspham wrote:How do I use this engine, like source? I tried downloading that and opening the .love in notepad++ and get a string of odd/weird character
.love sources are actually zipped folders. Rename it to .zip and unzip it to get the folder with the file sources. More info here
https://love2d.org/wiki/Game_Distribution

Re: Platformer game engine (a proper one, really!)

Posted: Tue May 15, 2012 7:18 pm
by Ruirize
Lap wrote:If you want to have anything framerate independent you are going to need to use the delta time (the dt in "love.update(dt)"). That will tell you the time between frames.
That's great and all, but friction doesn't work that way.

Re: Platformer game engine (a proper one, really!)

Posted: Wed May 16, 2012 7:32 am
by Ellohir
Ruirize wrote:
Lap wrote:If you want to have anything framerate independent you are going to need to use the delta time (the dt in "love.update(dt)"). That will tell you the time between frames.
That's great and all, but friction doesn't work that way.
How does it work then?

Re: Platformer game engine (a proper one, really!)

Posted: Wed Jul 08, 2015 12:20 am
by Sarcose
Hey friend. Sorry to necro-post, but I couldn't find an answer to this and I thought this bore addressing: there is a crash in the "doors" map that seems to occur when the player is in a spot where the door will land or between the door and the spot it will land, but not if the player is very close to (like within a few pixels) or touching the door. Further testing revealed that the game crashed with the same error in "Islands" if I fall, and if I actually try to exit "Doors" via the door at the end. The error is as follows:

Code: Select all

Error

block.lua:31: attempt to call field 'drawq' (a nil value)

Traceback

block.lua:31: in function 'draw'
player.lua:140: in function 'event' --doesn't have this line on level-exit crash
level.lua:198: in function 'draw'
main.lua:79: in function 'draw'
[C]: in function 'xpcall'
Since no one has posted anything like this in the thread, I am guessing this has to do with a more recent update of the attachment of OP?

Re: Platformer game engine (a proper one, really!)

Posted: Wed Jul 08, 2015 7:22 am
by micha
The code seems to crash because it is written for an older version of LÖVE.

The function "drawq" was only available in older versions of LÖVE, I think up to 0.8. In the current verions 0.9.2 it has been removed and replaced by draw.

Re: Platformer game engine (a proper one, really!)

Posted: Wed Jul 08, 2015 8:28 pm
by NightKawata
Sarcose wrote:Hey friend. Sorry to necro-post, but I couldn't find an answer to this and I thought this bore addressing: there is a crash in the "doors" map that seems to occur when the player is in a spot where the door will land or between the door and the spot it will land, but not if the player is very close to (like within a few pixels) or touching the door. Further testing revealed that the game crashed with the same error in "Islands" if I fall, and if I actually try to exit "Doors" via the door at the end. The error is as follows:

Code: Select all

Error

block.lua:31: attempt to call field 'drawq' (a nil value)

Traceback

block.lua:31: in function 'draw'
player.lua:140: in function 'event' --doesn't have this line on level-exit crash
level.lua:198: in function 'draw'
main.lua:79: in function 'draw'
[C]: in function 'xpcall'
Since no one has posted anything like this in the thread, I am guessing this has to do with a more recent update of the attachment of OP?
Micha's post does explain it fully, and it is because this engine was written for 0.8.0.
Welcome to the forums, by the way!

I will give you one big tidbit of advice: In 3 years time, things made with LÖVE are probably going to be a bit broken. With every big release (0.7.2 -> 0.8.0, 0.8.0 -> 0.9.0), they're generally not backwards compatible.

If you want a good library and some pretty good documentation to build a platformer with, try this out!

Re: Platformer game engine (a proper one, really!)

Posted: Tue Aug 04, 2015 5:21 pm
by Sarcose
Hey thanks a lot for the help. Since I wrote that post and have been digging around a lot more/working on my code, I found someone post a tidbit of code that enables drawq compatibility with newer versions of LOVE:

Code: Select all

love.graphics.rdraw = love.graphics.draw
love.graphics.drawq = love.graphics.drawq or love.graphics.rdraw
function love.graphics.draw( ... )
   local args = { ... }
   if type(args[2]) == "userdata" then
      love.graphics.drawq(unpack(args))
   else
      love.graphics.rdraw(unpack(args))
   end
end
This was posted by HugoBDesigner in Small Useful Functions, and it's been invaluable. Might I just remark on how awesome Love2d and Lua are, that I was able to see this function and instantly know what to do with it to make it work in an already packaged game?

Thanks for the welcome. I'm definitely going to check out your link.