Platformer game engine (a proper one, really!)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Ruirize
Prole
Posts: 20
Joined: Tue Dec 13, 2011 9:02 pm
Location: England
Contact:

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

Post 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?
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

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

Post 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.
jspham
Prole
Posts: 3
Joined: Wed Apr 04, 2012 2:23 am

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

Post 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
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

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

Post 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
User avatar
Ruirize
Prole
Posts: 20
Joined: Tue Dec 13, 2011 9:02 pm
Location: England
Contact:

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

Post 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.
User avatar
Ellohir
Party member
Posts: 235
Joined: Sat Oct 22, 2011 11:12 pm

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

Post 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?
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

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

Post 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?
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

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

Post 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.
User avatar
NightKawata
Party member
Posts: 294
Joined: Tue Jan 01, 2013 9:18 pm
Location: Cyberspace, Room 6502
Contact:

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

Post 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!
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Sarcose
Prole
Posts: 48
Joined: Wed Jul 08, 2015 12:09 am

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 90 guests