optimized obstacle collision and draw code