Added collision detection for entity movement.