The diagrams explaining it.
Sunday, May 29th, 2005Working on gravity still.
I have the movement down, but the hit detection is still wrong. The player eventually falls through the earth. The problem is with my hit detection method.
There are two obvious methods.
Method 1 moves the player to the ending position and checks if he is touching anything. If he is not, then it allows the move, if he is, it moves him back.
Method 2 Checks the space from the player’s starting position to the player’s next position for any objects besides the player itself. It’s more complex, not impossible. It’s not neccessarily slow either.
Here’s a diagram

The problem is when the player moves diagonally, it involves the equation for a line, and can be much more complex than this diagram, unless I cut corners, which could lead to weird gameplay.
Maybe I should work more on the code and not the diagrams explaining it though.