Log In  

Cart [#26324#] | Code | 2016-08-02 | License: CC4-BY-NC-SA | Embed


I'm trying to make a reusable platform game engine in the style of Super Mario Bros or Sonic the Hedgehog etc. I've just finished putting something together and I'd love to get any opinions on how it feels or ways to make it better. The graphics are extremely basic because I'm just focusing on the mechanics for now.

My biggest problem with it is in making jumping through platforms feel nice. Currently if the bottom of the player is intersecting a floor tile, the player is moved above it to stand on it. However this results in the player being put up on a platform when it doesn't feel like he should be. I'd like to make it so that a platform is only detected when the player's feet just slightly intersect it by up to half a tile.

Arrow keys to move
"Z" key to jump

-Horizontal and vertical acceleration
-Capped speeds
-Floor detection
-Variable jump height based on length of time button is held
-Variable jump height based on horizontal speed of player at time of jump

It seems to run slower in a browser than in Pico-8. My code isn't currently very efficient, perhaps that's the reason.

P#26325 2016-08-02 11:01 ( Edited 2016-08-19 10:51)

I ran into a lot of issues with ground checking when I tried to make a character jump. I was doing pixel color checking rather than map checking but maybe there's something from that discussion you can pick from too.


Not saying that solves or adds anything to your situation, just a thread about platform jumping.

P#26326 2016-08-02 11:25 ( Edited 2016-08-02 15:25)

Thanks for the link, it's an interesting idea doing it by colour. I guess doing that gives you more versatility in checking for collisions because of being able to do it on a pixel level rather than a tile level.

P#26328 2016-08-02 11:39 ( Edited 2016-08-02 15:39)
:: matt
P#26332 2016-08-02 12:10 ( Edited 2016-08-02 16:10)

That air is awfully thick.

Also, this particular combo of thin character, acceleration, platform width, sprite animation variation makes it pretty hard to land on single blocks.

P#26356 2016-08-02 21:42 ( Edited 2016-08-03 01:42)

@matt Thanks for that link, it's got a ton of useful information in it :)

@tyroney I think some of the "thick air" feeling is coming from it running slower in a browser. I might be wrong though. I'll keep working on trying to make it better.

P#26366 2016-08-03 05:40 ( Edited 2016-08-03 09:40)

Classic mario physics only have friction while you're on the ground. I let go of direction in the air and it almost felt like I'd hit a wall.

P#26384 2016-08-03 13:07 ( Edited 2016-08-03 17:07)

My typical solution for collision in multiple directions is to have unique logic if the player is moving up versus down (and left versus right). If the object is moving upwards check for ceilings and not floors, and vice versa.

P#26490 2016-08-04 19:31 ( Edited 2016-08-04 23:31)

Press right.

Press left while pressing right.

Release right.

This works both ways, actually.

I do like the friction so far, although I'd make it more forgiving on the ground, and less forgiving in the air.

P#26950 2016-08-15 12:22 ( Edited 2016-08-15 16:22)
:: mimick


By playing a little with it, i feel there is something strange with the inertia of the character.
He stops quite instantly when no direction are pushed but the delay to change direction is very high. There is also a bug when changing direction at max speed, the character doesn't take account the button is pressed (it is because at max speed the acceleration is set to 0, and when a button is pressed the friction is set to 0, then the speed which depends of acceleration and friction doesn't change).

To manage speed limit and friction, why doesn't do like in jelpi : speed*=friction (with 0<friction<1) . It automatically stops the character and also it is an implicit speed limit management : at a high speed, the friction becomes higher than the acceleration.
For a more "like mario" feeling, you could consider that when the character changes direction, it doesn't modify the acceleration but the friction. (You could even make a brake state with a specific animation)

At high altitude, the falling speed is so high it make the character go through the plateform, you should also make a vertical speed limit to avoid this.

P#27074 2016-08-19 06:51 ( Edited 2016-08-19 10:57)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-10-21 10:31 | 0.032s | 2097k | Q:40