updated with collision and room detection