PDA

View Full Version : [Platformer]Slope detection/resolver



substance
May 12th, 2008, 03:42 PM
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 (It's about 2 minutes in)

Jerryscript
May 12th, 2008, 06:36 PM
Here's a good tutorial with source code on how to use vectors:

http://www.tonypa.pri.ee/vectors/start.html

coolcat
May 12th, 2008, 08:13 PM
Here's a good tutorial with source code on how to use vectors:

http://www.tonypa.pri.ee/vectors/start.html
sry but that doesnt help me too much i need it to be laid out for me so i can can easily do it:|

cooldude88
May 12th, 2008, 08:39 PM
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:

substance
May 12th, 2008, 09:54 PM
Here's a good tutorial with source code on how to use vectors:

http://www.tonypa.pri.ee/vectors/start.html

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

therobot
May 12th, 2008, 11:39 PM
sry but that doesnt help me too much i need it to be laid out for me so i can can easily do it:|

It is laid out quite clearly over multiple pages. You've just got your work cut out for you. :eye:

rrh
May 13th, 2008, 11:31 AM
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.

substance
May 13th, 2008, 03:43 PM
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

Hope this helps others intrested in platformers as well.