Possible Duplicate:
How do I calculate the angle of the slope at a point on a 2D bitmap terrain?
I am planning to make a platform game with my own little engine and I need to know how to detect the angle of a slope. Any help is appreciated.
I am planning to make a platform game with my own little engine and I need to know how to detect the angle of a slope. Any help is appreciated. |
||||
|
|
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
You need to know 2 points to calculate a slope, in this example you have
|
|||||||
|
|
You have two options, and it depends on how you plan to go about your game's collision detection. If the collision data for your levels can be represented as line segments (or other shapes that can be broken down into line segments), you can use atan2 to find the angle between the endpoints of each line segment as suggested by Thomas. If your game is tile-based, each tile would likely hold collision data that you've created manually. (E.g. tile type, angle of slope, etc.) |
|||
|
|