# \[Platformer\]Slope detection/resolver

**URL:** <https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123>\
**Category:** programming\
**Created:** [May 12, 2008, 7:42pm UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123 "2008-05-12T19:42:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![substance](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@substance](https://forum.kirupa.com/u/substance)\
**Post date:** [May 12, 2008, 7:42pm UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/1 "2008-05-12T19:42:32Z")

</div>

[http://teamimpulse9.com/Platformer/Platformer.html](http://teamimpulse9.com/Platformer/Platformer.html) (WASD to move)

I’m working on a adventure/platform game and I want to be able to include a stage with slopes and inclines.

My game works fine with flat ground and walls. What I did was create htiboxes for my charcter and if collision was detected it would calculate the angle of collision and set the charcters X velocity or Y velocity to 0. However, this method doesnt work well with inclines and slopes for obvious reasons.

Does anyone know the proper way in dealing with this? BTW, I dont think it matters but I am using BitmapData for my stage and collision (aka no hitTest).

EDIT\* I found a video that breifly shows an example of slope detection in action, however there is no explanation on it’s structure. [http://www.youtube.com/watch?v=c9li34vNSrY](http://www.youtube.com/watch?v=c9li34vNSrY) (It’s about 2 minutes in)

---

<div class="post-metadata">

**Author:** ![Jerryscript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jerryscript/32/451_2.png) [@Jerryscript](https://forum.kirupa.com/u/Jerryscript)\
**Post date:** [May 12, 2008, 10:36pm UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/2 "2008-05-12T22:36:17Z")

</div>

Here’s a good tutorial with source code on how to use vectors:

[http://www.tonypa.pri.ee/vectors/start.html](http://www.tonypa.pri.ee/vectors/start.html)

---

<div class="post-metadata">

**Author:** ![coolcat](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@coolcat](https://forum.kirupa.com/u/coolcat)\
**Post date:** [May 13, 2008, 12:13am UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/3 "2008-05-13T00:13:32Z")

</div>

[quote=Jerryscript;2325278]Here’s a good tutorial with source code on how to use vectors:

> **['The Pass' has a Bunch of Browser Based Games - To NY pa...](http://tonypa.pri.ee/pass-browser-based-games/)**
>
> This page has interesting information regarding 'The Pass' which has nothing but fun browser based and all sorts of other games all around New York City.

  
sry but that doesnt help me too much i need it to be laid out for me so i can can easily do it:|

---

<div class="post-metadata">

**Author:** ![cooldude88](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@cooldude88](https://forum.kirupa.com/u/cooldude88)\
**Post date:** [May 13, 2008, 12:39am UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/4 "2008-05-13T00:39:40Z")

</div>

well i havnt ever done this but ive seen it where the character has a small dot in frotn of him and im guessing that when the characte hits the ground it just rotates until it has the dot hit the ground but also you should try putting your left and right movement speeds into different variables for as it is now if you walk up to the wall your stuck. :party:

---

<div class="post-metadata">

**Author:** ![substance](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@substance](https://forum.kirupa.com/u/substance)\
**Post date:** [May 13, 2008, 1:54am UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/5 "2008-05-13T01:54:25Z")

</div>

[QUOTE=Jerryscript;2325278]Here’s a good tutorial with source code on how to use vectors:

[http://www.tonypa.pri.ee/vectors/start.html](http://www.tonypa.pri.ee/vectors/start.html)[/QUOTE]

Wow, that looks EXTREMELY usefull. I’ve been to that site before but for some reason I remember it being mostly about tiles.

---

<div class="post-metadata">

**Author:** ![rrh](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rrh](https://forum.kirupa.com/u/rrh)\
**Post date:** [May 13, 2008, 3:31pm UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/6 "2008-05-13T15:31:17Z")

</div>

I’m pulling this out of the air based on the Fancy Pants video, but try it that when the right dot hits the ground, rotate the four dots upward using the left dot as the centre point, and when the left dot hits the ground rotate using the right dot as the centre point.

---

<div class="post-metadata">

**Author:** ![substance](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@substance](https://forum.kirupa.com/u/substance)\
**Post date:** [May 13, 2008, 7:43pm UTC](https://forum.kirupa.com/t/platformer-slope-detection-resolver/260123/7 "2008-05-13T19:43:48Z")

</div>

Well even though tonypa’s tutorials are extremely usefull and I’ve learned alot after reading it over (quite a few times) his examples dont cover my specific problem.

However I did find a tutorial that looks like will explain exactly what I need. (cant look at now)

[http://worldfaction.com/forums/viewtopic.php?f=18&t=178](http://worldfaction.com/forums/viewtopic.php?f=18&t=178)

Hope this helps others intrested in platformers as well.
