Making mouse-detectable zones

Blitz3D Forums/Blitz3D Beginners Area/Making mouse-detectable zones

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It'll work, you just need slightly more complicated math. I'm using the same approach with the hexagon tiles in my game.

For a diamond-shaped map, you'll need to take into account both the X and Y position of the mouse when determining each of tile_x and tile_y. Something like this should work for you:
Const map_tile_offset_x = 32, map_tile_offset_y = 16
x_off# = MouseX() - map_origin_x
y_off# = MouseY() - map_origin_y
tile_x = Floor(x_off/map_tile_offset_x + y_off/map_tile_offset_y)
tile_y = Floor(y_off/map_tile_offset_y - x_off/map_tile_offset_x)
You'll also need to add 1 to both tile coordinates if your map originates at (1,1) instead of (0,0).