Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i'm trying to do a pixel perfect collision but i don't know how to handle collisions when there is a jump . Here i have one image of a sample map:

enter image description here

But maybe I've done a bad supposing all pixel like little collision points . I mean , there is no differences between y-axis collision and x-axis collision in my collision map.

I have been treating each axis collision split , but that is bad done when diagonal jump have been made , cause you'll made an error in x or in y while correcting the position.

Then I thought that maybe I was wrong in my supposition that I didn't need to split for pixel collision type.

I will resume it in 2 questions:

  • how can I handle pixel perfect collisions for a platformer?
  • if I'm doing it well , How to manage the x-axis, y-axis problem?

P.S: My collision 'player' is a box way

share|improve this question
1  
I don't understand the problem description. Could you draw it? Also, "pixel perfect" might mean one of very many things. What does it mean here? –  Anko Mar 18 '13 at 14:04
add comment

1 Answer

There are different approaches you can use. For a start, I'd use a rather simple (maybe even a bit naive) approach:

You're essentially checking two points on your character for now:

  • The position where he's standing (feet; actually a bit right below the character).
  • The position of his head (head).

The character is then moved based on the following rules: - If feet is not solid, drop down. - While feet is solid, move up. - If feet and head both are solid, the character dies (squeezed). Ifheadis solid, stop vertical velocity/jumping. - Whilehead` is solid, move down.

Checking left/right works in a similar way. Doing this right will also solve stuff such as ramps instantly for you.

Reading through the poitns above, it should be clear, that you essentially "bounce" the character instead of having him standing still. This is true, but the player won't notice, because you don't draw inbetween these steps.

share|improve this answer
    
the question is that i can't stop the player cause he must go through the panels when jumping , and another thing is that if i move up the player maybe he musn't be there , he must maybe be on the left cause he couldn't have gone on the top. –  A.Quiroga Mar 18 '13 at 11:48
    
Ah, so those are jump-through platforms? Rather easy, you just exclude them when checking your head point. Once you've got these basics, you can check more positions (or just check rectangles rather than points). So you'd end up with 4 rectangles. The bottom one keeps you from falling through platforms, the top one keeps you from going into solid ceilings and the left/right one keep you from running/jumping into walls or ramps. –  Mario Mar 18 '13 at 12:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.