  SCREEN 12
  CLS
  PRINT "ball demo"
  PRINT " coded 2007"
  PRINT "------------"
  SLEEP
  CLS
  R = 0
  D = 0
  
  RANDOMIZE TIMER
  SP = 25
  
  DO
  ke$ = INKEY$
  
  IF R = 0 THEN X = X + SP: IF X > 620 THEN R = 1
   IF R = 1 THEN X = X - SP: IF X < 1 THEN R = 0
  IF D = 0 THEN Y = Y + SP: IF Y > 400 THEN D = 1
   IF D = 1 THEN Y = Y - SP: IF Y < 1 THEN D = 0
  
  
  
    PASS = PASS + 1
    IF PASS > 13 THEN
     JACK = INT(RND(1) * (4)) + 1
      IF JACK = 1 THEN R = 1
      IF JACK = 2 THEN D = 1
      IF JACK = 3 THEN R = 0
      IF JACK = 4 THEN D = 0
     
     PASS = 0
     SP = INT(RND(1) * (15)) + 1
    END IF
     
  
  
  C = C + 1: IF C > 16 THEN C = 0
  CIRCLE (X, Y), 30, 7: PAINT (X, Y), C, 7
   CIRCLE (x1, y1), 30, 0: PAINT (x1, y1), 0
   
    x1 = X2: y1 = Y2
     X2 = X3: Y2 = Y3
      X3 = X4: Y3 = Y4
       X4 = X5: Y4 = Y5
        X5 = X6: Y5 = Y6
         X6 = X7: Y6 = Y7
          X7 = X8: Y7 = Y8
           X8 = X9: Y8 = Y9
            X9 = X10: Y9 = Y10
             X10 = X: Y10 = Y
  
  LOOP UNTIL ke$ = CHR$(27)' rem <esc> exits
  
  
 
