Log In  


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


Hi!

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.

Controls:
Arrow keys to move
"Z" key to jump

Features:
-Horizontal and vertical acceleration
-Friction
-Gravity
-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.



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.

https://www.lexaloffle.com/bbs/?tid=3677

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


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.



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.


@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.


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.


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.


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.


Hello,

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.



[Please log in to post a comment]