I have accidentally made an infinite loop with my current collision detector. I know there is a good way to do this. Here's the relevant code:Block is simply a Block that should be collided with. The for loop is getting stuck, presumably because of the ceiling made of blocks causing an infinite loop. Help?
for(Actor floor = getOneObjectAtOffset(0, 0, Block.class); floor != null; floor = getOneObjectAtOffset(0, 0, Block.class)) { if(getOneObjectAtOffset(0, 1, Block.class) != null) { setLocation(getX(), getY() - 1); } else { setLocation(getX(), getY() + 1); break; } } Actor floor = getOneObjectAtOffset(0, 1, Block.class); if(floor == null) { setLocation(getX(), getY() + 1); }