Mario-style layer jumping

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Mario-style layer jumping

Post by GungnirDev »

OK, so I'm trying to do jumping again, the very first thing I tried to do when I joined the LÖVE forums.

I want the character to jump like Mario does in Super Mario World and the like, so that he can jump through the bottom of a layer to land on top of it. The idea being that they are layered hills behind one another, like this screenshot that I'm sure almost everyone has seen:

Image

Help, please? So far all I can do is either a very jarring jump between levels when you cross an arbitrary line, or the ability to jump/fall layers easily, but the inability to jump when you're under a layer. Can you assist?
Attachments
w.love
(239.39 KiB) Downloaded 101 times
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Mario-style layer jumping

Post by bartbes »

If the tiles are marked differently, it's fairly easy to check when to collide this way.
If you're using layers (which it sounds like, from your post), then you simply keep a "current layer", and don't collide with anything but the current layer while going upwards, so only if you cleared the floor on the next layer and you're going down, you can collide with it and switch layers.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Mario-style layer jumping

Post by micha »

thesmeagle wrote:I want the character to jump like Mario does in Super Mario World and the like, so that he can jump through the bottom of a layer to land on top of it. The idea being that they are layered hills behind one another, like this screenshot that I'm sure almost everyone has seen:
Super Mario is not using layers. It just makes it look like that. The green plateau in your graphic is just a platform that does not cause any collision from the below. So, if you want to imitate the Mario-like behaviour, there is no need for layers. Some Ideas on these kinds of platforms can be founde here: http://higherorderfun.com/blog/2012/05/ ... atformers/, scroll down to "One-way platforms".

On the other hand, layered maps might be really interesting and give nice new possibilities for puzzles and mazes.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Mario-style layer jumping

Post by Jasoco »

Modify your collision detection system to only check for that specific tile ID when the direction of the player (Or other character) is moving down. You could use the same method for other one-way tiles as well. Like ones that only let you fall down through but not jump back up. Or move through in one direction.
User avatar
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Re: Mario-style layer jumping

Post by GungnirDev »

I don't believe I'm presently using tiles OR layers (really, the game is extremely bare-bones right now, calling it alpha would be an embarrassment to alpha), but if you think those would work well for the project I would absolutely be willing to try either. It's basically supposed to be a series of different hill-platforms, but there won't be any side-scrolling on this particular project as I intend for it to resemble a tower-defense game. I don't know where to start, although I'm taking a look at micha's link and it looks promising.
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
User avatar
Puzzlem00n
Party member
Posts: 171
Joined: Fri Apr 06, 2012 8:49 pm
Contact:

Re: Mario-style layer jumping

Post by Puzzlem00n »

Jasoco wrote:Modify your collision detection system to only check for that specific tile ID when the direction of the player (Or other character) is moving down. You could use the same method for other one-way tiles as well. Like ones that only let you fall down through but not jump back up. Or move through in one direction.
According to the article just posted by Micha, actually, (which is a great article, by the way) that method is flawed. I quote from it:
It might be tempting to have it act as an obstacle if the player’s y speed is positive (that is, if the player is falling), but this behavior is wrong: it’s possible for the player to jump so he overlaps the platform, but then falls down again without having his feet reach the platform. In that case, he should still fall through.
Instead, the method suggested is that the collision only counts if your player is entirely above the platform before the movement occurred. The article explains it more in depth.

EDIT: To be clear, I have no idea if that really is the right way to do it, I'm only reading what it says and assuming it to be true. :)
I LÖVE, therefore I am.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 48 guests