Thursday, 19 September 2013

How would i find what column and row the mouse is in?

How would i find what column and row the mouse is in?

I need to find what column and row the mouse location is in. To simplify
this question, lets only find the column. I will write in pseudocode.
I have a map (a grid of rows and columns, made up by square cells) with a
pixel width. I have a cell size which makes up each columns pixel width.
eg map.width / cell size = map.NumberOfColumns.
From this we can get what column the mouse is on.
Eg if ( mouse.X > cellSize ) {col is definitely > 1} (i have not used zero
indexing in this example).
So if anyone here loves maths, i would very much appreciate some help.
Thanks.

No comments:

Post a Comment