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
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.
Look at the demos/collide sample shipped with pico. There is no built-in function to check collision.
[Please log in to post a comment]