L
L
lotrop2016-09-19 11:29:16
JavaScript
lotrop, 2016-09-19 11:29:16

Character movement at an angle?

How is the movement of the hero uphill, that is, at a certain angle, implemented in a game built on tiles (tiles)? Where can you read about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2016-09-19
@lotrop

I'll tell you how I did it. I wrote in Java ME, so there were no particularly complex ideas.
Each tile had an algorithmically defined surface (pavement). In newer versions of the engine, the ceiling was also attached - however, it doesn’t matter.
For simplicity, we introduce several restrictions. All of them, of course, cost complicated logic.
• A character cannot stand on anything other than tiles. Then you can get by with the flag: isSupported: true/false.
• Climbing the slope, the character will not hit his head on the ceiling. By the way, we had two different game design and two different approaches - when one saw this bug, he went to complain, the second took the pencil limit and did not make such levels.
• The bumps are big enough that you can check the legs on the left and the legs on the right - and it is clear at what height he should stand.
• The foot area/hitbox size ratio is large enough that while the character is falling, they are guaranteed to be pushed out of the wall.
Depending on the speed of the character and the steepness of the slopes, we will select epsilon - the range of the surface search.
Suppose our character is standing on something and move it to the right.
1. Move it to where it should be.
2. Let's try to adjust the height by taking the right side of the legs and finding a new surface in the range (y - epsilon, y + epsilon). The same with the left side of the legs. The one above is our new y. If it didn't work out - RESTRAINT (see step 3).
3. If at step 2 the character does not rest against the wall, check the entire hitbox for support. If it rests, we will push it out of the wall, adjust the height again according to principle 2.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question