Log In  

I am wondering how to detect collisions between a sprite and another sprite on the map. the latest thread for this was in 2016 and the code in the answers looked outdated. Thanks! G

P#54195 2018-07-15 20:43 ( Edited 2018-07-16 07:17)

My method is only precise to map tiles but there's this:

function cld(v)
 --this function returns the
 --tile that the xy coords
 --fall under. for collisions.
 return flr((4+v)/8)*8
end

Which is used in this:

function ccld(x,y,x2,y2)
 --this function compares 2 xy coords
 --and returns true or false
 --if they match.
 if cld(x)==cld(x2) and cld(y)==cld(y2) then
  return true
 else
  return false
 end
end

Hopefully that's somewhat helpful. I hope this thread gets more comments, because I'm sure there's a better way to do it but I haven't been able to wrap my head around it.

P#54196 2018-07-15 22:22 ( Edited 2018-07-16 02:22)

Look at the demos/collide sample shipped with pico. There is no built-in function to check collision.

P#54202 2018-07-16 03:17 ( Edited 2018-07-16 07:17)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 00:51:22 | 0.006s | Q:14