        rem REPAIR
        rem This 'droid stays put and repairs itself.
        rem When hit, it runs away to a new location and stays put.

            d=dmge: rem save old damage value

        100 if abs(dmge-d)<3 then 120 : rem check damage
                rem time to move to a random position
                x = random(400) + 50
                y = random(400) + 50
                gosub 400: rem move now
                d = dmge

        120 repair: rem repair robot
            goto 100

        400 REM This routine moves to a specific location and stops
        410 dx = x - xpos: dy = y - ypos
            xvel = dx * 3: yvel = dy * 3
            if abs(dx)<50 and abs(dy)<50 then xvel=0:yvel=0:return
            goto 410
