Skip to content

Instantly share code, notes, and snippets.

@sebmck
Created April 6, 2012 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmck/2318239 to your computer and use it in GitHub Desktop.
Save sebmck/2318239 to your computer and use it in GitHub Desktop.
<?php
class Collisions {
public static function CheckCollision($a, $b){
if(
$a->size == 0 || $b->size == 0 ||
!$a->ShouldCollide($b) || !$b->ShouldCollide($a) ||
$a->pos-x - $a->size > $b->pos->x + $b->size ||
$a->pos-x + $a->size < $b->pos->x - $b->size ||
$a->pos-y - $a->size > $b->pos->y + $b->size ||
$a->pos-y + $a->size < $b->pos->y- $b->size
){
return false;
} else {
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment