# Tile based collision with mouse

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

## 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 on other sites
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 on other sites
Quote:
 Original post by FortisVenaliterLet 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..

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 37
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631413
• Total Posts
2999945
×