// blocks public void checkBlocksCrush(ArrayList<Blocks> blocks, int i) { Blocks block = blocks.get(i); if (block.isDoor() && !block.isDoorOpen()) { if (enemiesSize <= 12 && enemiesSize > 7) { if (block.getX() > 0 && block.getX() < 2600) { blocks.get(i).setDoor(true); blockMove = true; } } else { if (enemiesSize <= 7 && enemiesSize > 3) { if (block.getX() > 2600 && block.getX() < 5500) { blocks.get(i).setDoor(true); blockMove = true; } } else { if (enemiesSize <= 3) { if (block.getX() > 5500) { blocks.get(i).setDoor(true); blockMove = true; } } } } } if (block.isTelekines()) { if (x - width / 2 > block.getX() + block.getWidth() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2 - height && y - height / 2 < block.getY() + block.getHeight() / 2 + height && !factingRight && x - width / 2 - block.getX() < 370) { blocks.get(i).setTelekinesTo(telekinesTo, false); if (!telekinesTo) blocks.get(i).setTelekinesFrom(telekinesFrom, true); } else { if (x + width / 2 < block.getX() - block.getWidth() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2 - height && y - height / 2 < block.getY() + block.getHeight() / 2 + height && factingRight && block.getX() - x - width / 2 < 370) { blocks.get(i).setTelekinesTo(telekinesTo, true); if (!telekinesTo) blocks.get(i).setTelekinesFrom(telekinesFrom, false); } else { blocks.get(i).setTelekinesTo(false, true); blocks.get(i).setTelekinesFrom(false, false); } } } if (block.isHorizontal()) { if (x + width / 2 > block.getX() - block.getWidth() / 2 + 5 && x - width / 2 < block.getX() + block.getWidth() / 2 - 5 && y - height / 2 < block.getY() - block.getHeight() / 2 && y + height / 2 >= block.getY() - block.getHeight() / 2) { if (reverse) { dy = -3; y = block.getY() - block.getHeight() / 2 - height / 2; } else { falling = false; x += block.getDX(); y = block.getY() - block.getHeight() / 2 - height / 2; } } else { if (x + width / 2 > block.getX() - block.getWidth() / 2 + 5 && x - width / 2 < block.getX() + block.getWidth() / 2 - 5 && y + height / 2 > block.getY() + block.getHeight() / 2 && y - height / 2 <= block.getY() + block.getHeight() / 2) { if (reverse) { falling = false; x += block.getDX(); y = block.getY() + block.getHeight() / 2 + height / 2; } else { dy = 3; y = block.getY() + block.getHeight() / 2 + height / 2; } } else { if (x - width / 2 < block.getX() - block.getWidth() / 2 && x + width / 2 >= block.getX() - block.getWidth() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2 && y - height / 2 < block.getY() + block.getHeight() / 2) { dx = 0; x = block.getX() - block.getWidth() / 2 - width / 2; } else { if (x + width / 2 > block.getX() + block.getWidth() / 2 && x - width / 2 <= block.getX() + block.getWidth() / 2 && y - height / 2 < block.getY() + block.getHeight() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2) { dx = 0; x = block.getX() + block.getWidth() / 2 + width / 2; } } } } } if (block.isVertical()) { if (x + width / 2 > block.getX() - block.getWidth() / 2 + 5 && x - width / 2 < block.getX() + block.getWidth() / 2 - 5 && y - height / 2 < block.getY() - block.getHeight() / 2 && y + height / 2 >= block.getY() - block.getHeight() / 2) { if (reverse) { dy = -3; y = block.getY() - block.getHeight() / 2 - height / 2; } else { falling = false; y = block.getY() - block.getHeight() / 2 - height / 2 + 4; } } else { if (x + width / 2 > block.getX() - block.getWidth() / 2 + 5 && x - width / 2 < block.getX() + block.getWidth() / 2 - 5 && y + height / 2 > block.getY() + block.getHeight() / 2 && y - height / 2 <= block.getY() + block.getHeight() / 2) { if (reverse) { falling = false; y = block.getY() + block.getHeight() / 2 + height / 2 - 4; } else { dy = 3; y = block.getY() + block.getHeight() / 2 + height / 2; } } else { if (x - width / 2 < block.getX() - block.getWidth() / 2 && x + width / 2 >= block.getX() - block.getWidth() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2 && y - height / 2 < block.getY() + block.getHeight() / 2) { dx = 0; x = block.getX() - block.getWidth() / 2 - width / 2; } else { if (x + width / 2 > block.getX() + block.getWidth() / 2 && x - width / 2 <= block.getX() + block.getWidth() / 2 && y - height / 2 < block.getY() + block.getHeight() / 2 && y + height / 2 > block.getY() - block.getHeight() / 2) { dx = 0; x = block.getX() + block.getWidth() / 2 + width / 2; } } } } } }