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.

If your tiles are arranged in a grid and won't be moving around or changing shape along the X and Y axis, you should be able to determine which tile was clicked on by simply dividing by the size of the tiles (and acounting for the map offset).
; 2d example
const map_origin_x = 383, map_origin_y = 389
const map_tile_width = 32, map_tile_height = 32
;;;
tile_x = floor((mousex()-map_origin_x) / map_tile_width)
tile_y = floor((mousey()-map_origin_y) / map_tile_height)
; 3d example
const map_origin_x = 0, map_origin_y = 0
const map_tile_width = 32, map_tile_height = 32
entitypickmode(map_entity, 2) ; 2=polygon
;;;
mouseover_entity = camerapick(global_camera, mousex(), mousey())
if mouseover_entity = map_entity then
	tile_x = floor((pickedx()-map_origin_x) / map_tile_width)
	tile_y = floor((pickedy()-map_origin_y) / map_tile_height)
endif