Added collision detection for entities