Sign in to follow this  
Makekk

Tile based collision with mouse

Recommended Posts

Makekk    122
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
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
Makekk    122
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this