Example #1
0
  public static boolean collision(int xCord, int yCord, boolean b) {

    if (GameData.isValid(xCord, yCord) && GameData.instance().blockMap[xCord][yCord] != null) {
      return true;
    }

    if (b) {

      Point p = Frame.game.m.cordToPos(xCord, yCord);
      Rectangle r1 = new Rectangle(p.x, p.y, 60, 60);

      for (int i = 0; i < GameData.instance().entityList.size(); i++) {
        Entity e = GameData.instance().entityList.get(i);

        if (e.isSolid()) {
          Rectangle r2 = e.getBounds();

          if (r1.intersects(r2)) {
            return true;
          }
        }
      }
    }

    return false;
  }
Example #2
0
 // Returns block at given coords.
 public static Block getBlock(int x, int y) {
   if (GameData.isValid(x, y)) {
     return GameData.instance().blockMap[x][y];
   } else {
     return null;
   }
 }