How can I fine-tune my movement values in a 2D block-based platformer?

I'm wondering how I can refine player movement/physics values, such as speed and jump height, to make it all work, while allowing the games to be fair and challenging. Is it simply trial and error, or is there a more standardized solution?

The levels in games like Super Mario or Geometry Dash are built on uniformly sized blocks, so the movement values need to work with these blocks. For example, if Mario can only jump 5 blocks high, the developers need to ensure that no obstacle is greater than 5 blocks tall (unless Mario has some special ability, but I'm not talking about that), or the player will be stuck.

Similarly, if the developers know that Mario can only jump 6.5 blocks horizontally, a blockless pit should be, at most, 6 blocks long. Knowing these relationships would allow one to create beatable levels, and even dynamically generate obstacles for the player to traverse.

I already have a character controller that can set my movement values easily, but I'm struggling to figure out a good way to make my movement and block sizes work together. Specifically, I'm concerned about making my game too easy or hard. How do I know when I've struck a proper balance?

• You might find this earlier discussion of tuning platformer level difficulty relevant to your problem. To make this more concrete, can you boil down a specific example of something you're unsatisfied with in your current movement value tuning, and we can suggest ways to improve that aspect of the experience? Every game is different - even among platformers I'm sure you've noticed there's not just one standard jump - so finding the right one for you is mostly about understanding your own creative intentions for the game. – DMGregory Jul 26 '19 at 7:55
• Your answer in the linked discussion was actually very similar to what I was looking for here. Thanks! – Ginger and Lavender Jul 26 '19 at 18:06

3 Answers

There is a lot you can do with a mathematical approach to game design, but in the end you won't get around systematic playtesting.

A good way to identify places in your game which are too hard are automatically collected metrics. Whenever the player dies, log when, where and exactly how they died. Put those events into a database, so you can analyze and visualize them. When you have the results of multiple playtesters, you can identify hotspots in your levels where players die a lot.

What's especially interesting are hotspots where the same players die repeatedly. What's even more interesting are hotspots where players die and then exit the game ("ragequits"). These might be parts of your game which are too difficult or even impossible to beat and cause frustration for the player.

See if you can make those sections easier by redesigning them or making sure players actually have the tools and knowledge required for beating that challenge at that point of the game.

Note that it should not be your goal to make the players not lose at all. If you try to disarm any difficult sections of your game, you might end up with a game which is so easy it's boring. Player death might even be a calculated part of your game experience, as long as proper anti-frustration features are in place. What you actually want to achieve is a game which is challenging, but has no sections which are so frustrating that they cause the player to quit or difficult spikes which require more skill from the player than what should be expected at that stage of the game.

And by the way: First nail down and polish the movement mechanics of your player-character in a couple test levels. Then start designing the real levels around those mechanics. If you keep tinkering with the movement while you already have levels in place, then you will break those levels and you will have to revise them over and over again.

I think the OP is not looking for a solution to a kinematic problem, but rather he is looking for methods to properly balance the game. I don't think there is any method in particular, but once you decide the parameters of the jumps or speed, it's a matter of doing a lot testing.

If you want to make it more "scientific", you could involve a sample of people who will test your game, and give them a questionnaire. If the questions can be answered with numbers, you can then perform a statistical analysis of the data you collected. For example, for the question "grade the difficulty of level X between 1 and 10", you could compute the average of the answers, or better inspect the histogram (see https://en.m.wikipedia.org/wiki/Histogram ). This will allow to discriminate between "level X is easy/difficult for basically everyone" and "many people find it hard, but also many people find it easy" which will help you in deciding how to tweak your parameters.

See also my answer to this question grade How to compute the moves amount in a match-3 game?

Jump height

The approach is: when Mario just has jumped, his kinetic energy is $$\ mv^2 \over 2 \$$ and potential energy is zero due to zero height, and in highest point of jump trajectory his potential energy is $$\ mgh \$$ and kinetic is zero due to zero speed. They are equal because of the law of energy conservation: $$\ v^2 = 2gh \$$ (I've already simplified this). Here is assumed that $$\ v_x = 0 \$$.

So, if you have

• $$\ h = 3\mbox{ tiles} = 48 \mbox { px} \$$
• $$\ g = 0.5 \mbox{ px/tick}^2 \$$

Then $$\ v = \sqrt {2 \cdot 0.5 \cdot 48} \approx 7 \mbox { px/tick} \$$.

But a game engine may be not that accurate and jump speed will still require manual tuning, you may want to use 3.5 tiles instead of 3.

Run speed

We calculate jump time based on height difference between start and finish, knowing jump velocity. Assuming that initial height is 0, we have this equation:

$$\ h = v_yt - {g \over 2}t^2 \$$

You have to find t. Usually there will be two roots because Mario will reach height h twice. Choose the one which is greater - it corresponds to jump phase when he descends. If there are none, then h is too high for him.

When t is found, you can easily find horizontal velocity for required path s:

$$\ s = v_xt \$$

$$\ v_x = {s \over t} \$$

• What are the names of these equations? I'd like to be able to read more about them in general so I can better understand what's going on. – Ginger and Lavender Jul 26 '19 at 18:13
• @GingerandLavender these can be derived from the kinematic equation for ballistic motion p(t) = p(0) + v(0)*t + 0.5*a*t*t which describes the motion of a body under constant acceleration a given its initial position p(0), initial velocity v(0), and elapsed time t. – DMGregory Jul 26 '19 at 21:46
• There is a small mistake on the equation for the landing time t, it should read h = v_y * t - 0.5 * g * t^2 since you defined v as the magnitude of the velocity, when talking about the energy above. – Turms Jul 27 '19 at 0:56
• @Turms you're right. I assumed that v is v_y in that equation. I'll edit the post to clarify it. – trollingchar Jul 27 '19 at 14:29