Platformer game engine (a proper one, really!)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
YellowAfterlife
Prole
Posts: 29
Joined: Mon Jan 23, 2012 4:05 pm
Contact:

Platformer game engine (a proper one, really!)

Post by YellowAfterlife » Mon Mar 12, 2012 1:00 am

Image
Old screenshots: (1.0.0)
So I've seen a couple of platformer game tutorials for Love2d. Some have used physics for making player jump. Some sucked. Some succeed at both things.
Later someone asked me to make a proper, optimized tutorial for these. So I did.
Attachment contains most of functional part. Things missing are more detailed comments at some places, and step-by-step introduction to it - will be done tomorrow. As for now, you can play existing levels, add your own ones (levels are stored in accessible string format), and do whatever other things you can manage to.

Main concepts:
Game is split into blocks and entities.
Blocks are static object of fixed dimensions, which can hold variables and trigger events. Behaviour of these can be edited directly and dynamically (in example, 'toggle' block toggles its own drawn event between value and nil, appearing and disappearing).
Objects are dynamic entities, which obey their prototype 'meta' object behaviour. They can be placed freely, and controlled more widely than blocks.

Both blocks and objects have 4 base events - create (executed on creation), destroy (executed on destruction), update (executed on love.update), and render (executed on love.render).

Collisions with blocks can be done via level.check function, which takes a 'rectangle' (4 parameters) and a filter function, which determines if block meets conditions of check or not.
Collisions with objects can be done via level.meet function, which will return array of objects of given type that overlap given rectangle. Further conditions for these must be implemented separately.
Implementations of both are available in example.

For the sake of simplicity, objects are presented as a single unsorted array which game iterates through.

Platformer engine itself is kept simple and framerate-independent.

Comments, suggestions, and other things are welcome.
Have a nice day.
Attachments
platformer-1.0.5.love
Version 1.0.5 (15/03/2012)
(58.29 KiB) Downloaded 2476 times
Last edited by YellowAfterlife on Wed Mar 14, 2012 11:10 pm, edited 3 times in total.
yal.cc
Contains things I work on. Also gets Love2d examples time to time.

User avatar
teh8bits
Citizen
Posts: 52
Joined: Fri Mar 09, 2012 9:18 pm
Location: The Matrix
Contact:

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

Post by teh8bits » Mon Mar 12, 2012 1:15 am

Wow very very very very nice :awesome:
Although you can jump again if you touch the side of another block even if you didn't land onto it, you probably knew this already and might even be intended.
EDIT:
Wait, nevermind. I must have seen it wrong. Very nice job :)

EDIT2:
Wait again, actually on the Islands level, the one block floating, when jumping to it it seems like theres a little bit of leeway on what constitutes as on top of it or something, or maybe it's just me. I only notice it there though.

User avatar
veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

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

Post by veethree » Mon Mar 12, 2012 1:44 am

This is good. I like it. This might be an issue with my computer, but i got pretty low FPS at times. And when that was happening the player went a bit into the tiles at times. but other than that it's great.

User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

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

Post by timmeh42 » Mon Mar 12, 2012 5:21 pm

You should probably restart the level when the player falls out of a certain area, say when they cant see any blocks.
Also, the "Lava" level is kind of irritating to start, but i guess that's nothing to do with the engine.

User avatar
killer64
Prole
Posts: 14
Joined: Mon Mar 12, 2012 7:55 pm

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

Post by killer64 » Mon Mar 12, 2012 9:12 pm

best platformer ive seen using love
i dont like the textures though
so i made my own!
1. mine 2. original 3. guess -_-
download: http://dl.dropbox.com/u/55181333/my%20textures.zip
Image
Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.

User avatar
Jasoco
Inner party member
Posts: 3650
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post by Jasoco » Tue Mar 13, 2012 12:45 am

Apparently you all forgot about the two attempts I made a while ago.

The first one: viewtopic.php?t=1905
Image

The second one never had a thread but the engine works much better. It's on hiatus right now. But I did post a screenshot a while ago in the "What Are You Working On?" thread.
viewtopic.php?f=3&t=2198&p=36687#p36674

Image

I'm kind of partial to the second one. I think it was adorable. Hopefully I'll get back to working on it soon after I finish with my current 3D Wolf engine and my super awesome sekret engine I've been working on lately. I kind of hit a wall when I implemented platforms incorrectly even though I'd had them correctly implemented in the previous engine.

And yes, by "proper" I do mean "no Box2d" as well.

Oh, and don't forget about the current champion of ultimate 2D side-scrolling platformer engines built with Löve. Mari0. I'd say Maurice won the internet with that one for now.
Last edited by Jasoco on Tue Mar 13, 2012 12:54 am, edited 3 times in total.

User avatar
teh8bits
Citizen
Posts: 52
Joined: Fri Mar 09, 2012 9:18 pm
Location: The Matrix
Contact:

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

Post by teh8bits » Tue Mar 13, 2012 12:49 am

All this talk inspired me to make my own, I might have something I feel worthy of sharing by the end of the week ;P

User avatar
YellowAfterlife
Prole
Posts: 29
Joined: Mon Jan 23, 2012 4:05 pm
Contact:

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

Post by YellowAfterlife » Tue Mar 13, 2012 1:19 am

teh8bits wrote:Wow very very very very nice :awesome:
Although you can jump again if you touch the side of another block even if you didn't land onto it, you probably knew this already and might even be intended.
EDIT:
Wait, nevermind. I must have seen it wrong. Very nice job :)

EDIT2:
Wait again, actually on the Islands level, the one block floating, when jumping to it it seems like theres a little bit of leeway on what constitutes as on top of it or something, or maybe it's just me. I only notice it there though.
It was a quirk of platformer engine, that was caused by order of actions (first move horizontally, then check for ground and jumps, then move vertically) and 'lucky' physics line-up, which have made it possible to 'bounce' on edge of block in some cases. Re-aligned these now for more normal behaviour.
veethree wrote:This is good. I like it. This might be an issue with my computer, but i got pretty low FPS at times. And when that was happening the player went a bit into the tiles at times. but other than that it's great.
You can try again the current version, I believe I've fixed possible horizontal movement glitch when 'time delta' gets really high.
timmeh42 wrote:You should probably restart the level when the player falls out of a certain area, say when they cant see any blocks.
Also, the "Lava" level is kind of irritating to start, but i guess that's nothing to do with the engine.
"Lava" level is meant to have difficulty. Since now you can't just jump out of level, it should be easier to not mess up with it.
killer64 wrote:best platformer ive seen using love
i dont like the textures though
so i made my own!
1. mine 2. original 3. guess -_-
download: http://dl.dropbox.com/u/55181333/my%20textures.zip
(image)
Hey, thanks for idea!
Textures included were actually the first remotely-fitting ones that I've found in my collection of earlier made assets.
I have re-drawn ('drawn' isn't an entirely correct term in this case, but anyway) textures for current version, having your edit in mind.
Jasoco wrote:Apparently you all forgot about the two attempts I made a while ago.

The first one: viewtopic.php?t=1905
...
Oh wow, never seen that. Why isn't there an engine\tutorial index thread?
Behaves... really oddly on Love 0.8 though - require with '.lua' extension wasn't such a good idea, and after editing that, game just lags out on first frames. Maybe you could make a small update to that if you're highlighting it here.
Anyhow, here I aim for something universal, rather than specific kind of game. For this reason objects and blocks are behaviour-driven rather than just hard-coded into engine. Personally I tend to give up on things when not making them easy to work with from beginning.

And, an update:
Image
Engine-sided changes:
  • Have split one large source into smaller categorized ones
  • Moved level arrays ranges from (1..size) to (0..size-1) to make things easier in object implementations
  • Re-named few methods to make sense.
  • Added more comments, explaining methods and actions inside of them
Demonstration-sided changes:
  • Re-made the textures. Lava now has a 16-frame animation and other things just look better.
  • Improved coin behaviour.
  • Limited players ability to walk out of level, and added restart upon falling out of it vertically.
  • Added a behaviour for animated block
  • Added a nice border around the things, and UI under it
  • Tossed around code of player update event to make it more universal and usable for non-fixed horizontal speed.
  • Added some more levels. Can you collect all 26 coins without dying?
yal.cc
Contains things I work on. Also gets Love2d examples time to time.

User avatar
teh8bits
Citizen
Posts: 52
Joined: Fri Mar 09, 2012 9:18 pm
Location: The Matrix
Contact:

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

Post by teh8bits » Tue Mar 13, 2012 1:31 am

Played it, loved it, love it still, amazing work :)
The lava animations are a really nice touch, I was working on something like this for my Forest Sword engine in Java, but I have no idea how to do it in Lua yet lol.

User avatar
veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

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

Post by veethree » Tue Mar 13, 2012 3:59 am

Tried the new version. And yes. The FPS issue seems fixed. The player can still get lodged inside the moving/teleporting/whatever you want to call them tiles.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests