line drawing algorithm, later used for collision detection