Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Zoomby

tile-engine problem

This topic is 5753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi! I have an annoying problem with my tile-engine. when the player (freely movable), hits a wall, i.e. a left-side wall, and you keep the left-arrow-key pressed, you can''t move up or down along the wall. This is because when a sprite collides with a tile, the sprite is moved back, until it collides no more. how can this problem be solved? bye chris

Share this post


Link to post
Share on other sites
Advertisement
You could try only moving it back along the axis perpendicular to the wall... So if they hit a north-south facing wall you reset their x position so that they''re no longer ''inside'' the wall, but you leave their z position unaffected.

Share this post


Link to post
Share on other sites
hi

The next problem is, I can''t really say which side of a Wall (Tile) the sprite hits. I tried something with vectors, but it''s sometimes inaccurate. Is there a good algorithm, to determine which side of a tile a sprite is hitting? Would this also work with a complex map (small tiles, and big sprites)?

bye
chris

Share this post


Link to post
Share on other sites
What I do in my engine, is first try the move left. If that fails, bring the sprite back to it''s original position. Then try the move up. That one should succeed in your case. This method works great for me.

Share this post


Link to post
Share on other sites
The method I use is a slightly more sophisticated variation of the OP''s approach: Before moving a sprite, check which directions it can move in. This is very simple: If the sprite is moving right, move it one pixel to the right and check for collisions, then move it back, et cetera.

If it''s trying to move in any direction that is blocked, set the velocity in that direction to zero. Once impossible movements are thus ruled out, move the sprite; if there are collisions, move it back (pixel by pixel) along the velocity vector until there are no more collisions; then it''s done.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!