Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBeerNutts

Posted 23 October 2012 - 11:41 AM

There are 2 things I would do to straighten up the code.

#1, have a separate function to check for input, and apply velocities to the player there instead of checking for keys in the movement location. This will help both in movements and collision detection.

#2, If you have a list of objects your player can collide with, then, every frame, have him check that list and see if he's collided. Realize, for platformers, you'll need to check specifically for collisions along the X-axis (to stop the player moving horizontally, while he's still moving vertically), and and Y-axis (to bump his head, or just bump his feet, if you want them to pass through the bottom of platforms).

There are a few posts about this that I've replied too that has some good info (with pseudo code) that handles moving and jumping in a platformer. Please check them out Here and Here

#1BeerNutts

Posted 23 October 2012 - 11:40 AM

There are 2 things I would do to straighten up the code.

#1, have a separate function to check for input, and apply velocities to the player there instead of checking for keys in the movement location. This will help both in movements and collision detection.

#2, If you have a list of objects your player can collide with, then, every frame, have him check that list and see if he's collided. Realize, for platformers, you'll need to check specifically for collisions along the X-axis (to stop the player moving horizontally, while he's still moving vertically), and and Y-axis (to bump his head, or just bump his feet, if you want them to pass through the bottom of platforms).

There are a few posts about this that I've replied too that has some good info (with pseudo code) that handles moving and jumping in a platformer. Please check them out Here and Here

PARTNERS