• Advertisement
Sign in to follow this  

Tile based collision with mouse

This topic is 3593 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 a problem when making tile based collision with mouse. I´m using BlitzMax... So, for now on I have made it so that it gets your mouse coordinates twice and when the collision with the tile happends it moves mouse to the place where the mouse was before the collision.. and it pretty much sucks. Infact, if you move the mouse enough fast it totally unrecognises the whole collision. Is there some better way to do the collision?

Share this post


Link to post
Share on other sites
Advertisement
Let me see if I understand you properly.
You want to keep the mouse inside a certain area defined by 'wall' tiles in a tile based system?

What you need to do is interpolate the mouse positions. Each frame store the mouse position.
The next frame, use that position and the new one to make a line segment representing the movement of the mouse. After that, determine if the line intersects a 'wall' tile, and if so, place the mouse at the point of intersection.

There are a lot of tutorials/methods on 2D line-rect collisions, so you can find that pretty easy by just googling it.

Regards,
FortisVenaliter

[Edited by - FortisVenaliter on April 24, 2008 11:27:24 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by FortisVenaliter
Let me see if I understand you properly.
You want to keep the mouse inside a certain area defined by 'wall' tiles in a tile based system?

What you need to do is interpolate the mouse positions. Each frame store the mouse position.
The next frame, use that position and the new one to make a line segment representing the movement of the mouse. After that, determine if the line intersects a 'wall' tile, and if so, place the mouse at the point of intersection.

There are a lot of tutorials/methods on 2D line-rect collisions, so you can find that pretty easy by just googling it.

Regards,
FortisVenaliter


It´s like the game is played with mouse and the player is 22x22 image that moves in a world made of 32x32 tiles that some of them should be not crossed..

I would be happy if you or some other could point me to somewhere to find the collision detection but anyways I will keep looking..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement