Discord
Login
Community
DARK THEME

How do I detect what cell of a map a sprite is on

How do I detect what cell of a map a set of coordinates are on

https://microstudio.dev/i/TwiceUponATime/tilemapcollision/

https://microstudio.dev/i/gilles/quickengine/

Quick.mapCellAt = function(map,x,y)
  local blockw = map.width/map.map.width
  local blockh = map.height/map.map.height
  local cx = floor((x-(map.x-map.width/2))/blockw)
  local cy = floor((y-(map.y-map.height/2))/blockh)
  return map.map.get(cx,cy)
end

Thanks!

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community