Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Collision Detection While Jumping  (Read 1757 times)

0 Members and 1 Guest are viewing this topic.

rojan_neo

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • http://makeagame.tumblr.com
Collision Detection While Jumping
« on: August 20, 2011, 12:14:06 pm »
I have a bounding box collision detection system setup... It works fine... My problem is while the player is jumping how can i make him fall down when he hits a wall... for eg: in mario when player jumps up and hits a wall with his head he starts falling down from there.. How do I achieve this

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Collision Detection While Jumping
« Reply #1 on: August 20, 2011, 12:31:05 pm »
Your player should have a position and velocity vector, where the latter determines the change in the former per time.

Set the Y component of the velocity vector to zero when the player hits the wall. Gravity continuously increases it, leading to the accelerated fall.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

rojan_neo

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • http://makeagame.tumblr.com
Collision Detection While Jumping
« Reply #2 on: August 20, 2011, 12:42:50 pm »
yes, I tried that.. and it makes my player fall perfectly but how am I suppose to get the player to jump again after a while because the velocity seems to be 0 for the rest of the game :?: