Function to check if 2 objects collide. Very useful for games.
arguments:
a: object 1 x
b: object 1 y
c: object 1 width
d: object 1 height
e: object 2 x
f: object 2 y
g: object 2 width
h: object 2 height
| function(a,b,c,d,e,f,g,h){return a<e+g&&a+c>e&&b<f+h&&b+d>f} |
| function(a,b,c,d,e,f,g,h){return a<e+g&&a+c>e&&b<f+h&&b+d>f} |
| { | |
| "name": "BoxCollisionCheck", | |
| "description": "function to check if 2 objects collide", | |
| "keywords": [ | |
| "collision", | |
| "box", | |
| "game" | |
| ] | |
| } |
| <!DOCTYPE html> | |
| <title>Foo</title> | |
| <div>Expected value: <b>undefined</b></div> | |
| <div>Actual value: <b id="ret"></b></div> | |
| <script> | |
| // write a small example that shows off the API for your example | |
| // and tests it in one fell swoop. | |
| var myFunction = function(){ /* the code here should be identical to the entry. */ } | |
| document.getElementById( "ret" ).innerHTML = myFunction() | |
| </script> |
@atk sweet!