        rem DMGE
        rem This droid moves away to a new position whenever
        rem it is damaged.

        100 d=dmge : rem save current damage value
        110 rem do some processing here
            if d=dmge then 110: rem continue with processing
            rem we've been hit! So move to a random position.
            x = random(400) + 50
            y = random(400) + 50
            gosub 400: rem move now
            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
