Finding correct spot in an array

Blitz3D Forums/Blitz3D Programming/Finding correct spot in an array

Tracer(Posted 2005) [#1]
I have the following 'grid' on screen:



Each number is an entry in an array, the array is Dim grid(9).

I have having trouble getting the number from each grid.. i know which x,y grid coord the mouse is over, but i need to somehow make those coords into the array entry number.

So, basically.. if the mouse is over grid position 2x2, it should return 5 (my array starts at one). If the mouse is over grid position 2x1, it should return 2.

Any ideas? I've been trying for the last hour or three and it's starting to tick me off :)

Tracer


Floyd(Posted 2005) [#2]
3*y + x - 3


Tracer(Posted 2005) [#3]
Awesome, thanks Floyd.

Tracer