Skip to main content
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Here's why you probably don't want to use a rounded rectangle to try to fix your problem:

Hmm

Now, getting stuck on the edge like that is probably just as frustrating, if not more, than not being able to move right at all.

I think you probably want to employ some error correction when you move. What I mean is, when your character moves, let's say, right, if there's a collision don't move back right away! Instead, move the rectangle up and down about 5 pixels (1 pixel at a time) to see if it can avoid a wall. Same for the other arrows. When moving up, if there's a collision, check if you can avoid it by moving left and right.

I've posted an answer similar to this before which you might find helpful:

How can I detect a perfect passageway for collision detection?How can I detect a perfect passageway for collision detection? // see method 1

The second thing you can do here which is common in a lot of tile games like yours is to move the character exactly 1 tile every time you move. So if you tap the right arrow and then release it after the character only moves a few pixels, the character will keep moving until it is in the center of the next tile.

Hope this helps! :)

Here's why you probably don't want to use a rounded rectangle to try to fix your problem:

Hmm

Now, getting stuck on the edge like that is probably just as frustrating, if not more, than not being able to move right at all.

I think you probably want to employ some error correction when you move. What I mean is, when your character moves, let's say, right, if there's a collision don't move back right away! Instead, move the rectangle up and down about 5 pixels (1 pixel at a time) to see if it can avoid a wall. Same for the other arrows. When moving up, if there's a collision, check if you can avoid it by moving left and right.

I've posted an answer similar to this before which you might find helpful:

How can I detect a perfect passageway for collision detection? // see method 1

The second thing you can do here which is common in a lot of tile games like yours is to move the character exactly 1 tile every time you move. So if you tap the right arrow and then release it after the character only moves a few pixels, the character will keep moving until it is in the center of the next tile.

Hope this helps! :)

Here's why you probably don't want to use a rounded rectangle to try to fix your problem:

Hmm

Now, getting stuck on the edge like that is probably just as frustrating, if not more, than not being able to move right at all.

I think you probably want to employ some error correction when you move. What I mean is, when your character moves, let's say, right, if there's a collision don't move back right away! Instead, move the rectangle up and down about 5 pixels (1 pixel at a time) to see if it can avoid a wall. Same for the other arrows. When moving up, if there's a collision, check if you can avoid it by moving left and right.

I've posted an answer similar to this before which you might find helpful:

How can I detect a perfect passageway for collision detection? // see method 1

The second thing you can do here which is common in a lot of tile games like yours is to move the character exactly 1 tile every time you move. So if you tap the right arrow and then release it after the character only moves a few pixels, the character will keep moving until it is in the center of the next tile.

Hope this helps! :)

Source Link
Superdoggy
  • 527
  • 4
  • 16

Here's why you probably don't want to use a rounded rectangle to try to fix your problem:

Hmm

Now, getting stuck on the edge like that is probably just as frustrating, if not more, than not being able to move right at all.

I think you probably want to employ some error correction when you move. What I mean is, when your character moves, let's say, right, if there's a collision don't move back right away! Instead, move the rectangle up and down about 5 pixels (1 pixel at a time) to see if it can avoid a wall. Same for the other arrows. When moving up, if there's a collision, check if you can avoid it by moving left and right.

I've posted an answer similar to this before which you might find helpful:

How can I detect a perfect passageway for collision detection? // see method 1

The second thing you can do here which is common in a lot of tile games like yours is to move the character exactly 1 tile every time you move. So if you tap the right arrow and then release it after the character only moves a few pixels, the character will keep moving until it is in the center of the next tile.

Hope this helps! :)