Advertisement
ulfben

intersectsAABB (Intro Android 2018)

Jan 28th, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. //for Entity.java
  2. public boolean isColliding(Entity that){
  3.     return Entity.intersectsAABB(this, that);
  4. }
  5.  
  6. public void onCollision(Entity that){
  7.     // no default implementation
  8. }
  9.  
  10. public static boolean intersectsAABB(Entity a, Entity b) {
  11.     return !(a.right() < b.left()
  12.             || b.right() < a.left()
  13.             || a.bottom() < b.top()
  14.             || b.bottom() < a.top());
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement