Пример #1
0
 public boolean canMove(float tx, float ty) {
   // check world limit
   if (tx < 0 || tx >= world.getWidth() || ty < 0 || ty >= world.getHeight()) {
     return false;
   }
   return c.collide(Entity.SOLID, tx, ty) == null
           && c.collide(G.TRAP, tx, ty) == null
           && c.collideWith(G.playerEntity, tx, ty) == null
       ? true
       : false;
 }
Пример #2
0
 protected void move(int i, int j) {
   int tx = (int) (c.x + i * G.TILE_SIZE);
   int ty = (int) (c.y + j * G.TILE_SIZE);
   // check world limit
   if (tx < 0 || tx >= world.getWidth() || ty < 0 || ty >= world.getHeight()) {
     return;
   }
   // check collision
   if (c.collide(c.SOLID, tx, ty) == null || c.collide(G.TRAP, tx, ty) == null) {
     c.x = tx;
     c.y = ty;
   }
   // checkCollision(tx, ty);
 }