Advertisement
dermetfan

Tiled Map Game (LibGDX) Episode 4 update better methods

Oct 10th, 2013
1,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public boolean collidesRight() {
  2.     for(float step = 0; step < getHeight(); step += collisionLayer.getTileHeight() / 2)
  3.         if(isCellBlocked(getX() + getWidth(), getY() + step))
  4.             return true;
  5.     return false;
  6. }
  7.  
  8. public boolean collidesLeft() {
  9.     for(float step = 0; step < getHeight(); step += collisionLayer.getTileHeight() / 2)
  10.         if(isCellBlocked(getX(), getY() + step))
  11.             return true;
  12.     return false;
  13. }
  14.  
  15. public boolean collidesTop() {
  16.     for(float step = 0; step < getWidth(); step += collisionLayer.getTileWidth() / 2)
  17.         if(isCellBlocked(getX() + step, getY() + getHeight()))
  18.             return true;
  19.     return false;
  20. }
  21.  
  22. public boolean collidesBottom() {
  23.     for(float step = 0; step < getWidth(); step += collisionLayer.getTileWidth() / 2)
  24.         if(isCellBlocked(getX() + step, getY()))
  25.             return true;
  26.     return false;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement