The most useful function

I find that this is my most used, most useful function: the simple box collision.

function isCol(thex,they, othx, othy, thel, theh, othl, othh){
return !(they+theh <= othy || they >= othy+othh || thex+thel <= othx || thex >= othx+othl);
}

Comments

Snowdrama
26. Mar 2016 · 19:49 UTC
I like this, It took me a bit to realize you were testing to make sure it was NOT colliding and then flipping the response. Normally I would do it backwards, Test each point to see if it was inside the box, so it was twice as long.