home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0963.lha
/
SIOD
/
scm
/
demo.scm
< prev
next >
Wrap
Text File
|
1993-10-01
|
2KB
|
43 lines
(define (locate x y p)
(display #\ p) (display #\[ p) (display x p) (display #\; p)
(display y p) (display #\H p))
(define (demo . size)
(define p (open-port "CON:0/0/640/200/The snake. (Control-C to stop)" "w" 0))
(define mem (make-vector 4 nil))
(define pos (make-vector 4 (cons (random 23) (random 75))))
(define tmp nil)
(define tmpmem nil)
(define tmppos nil)
(if (null? size)
(set! size 8)
(set! size (car size)))
(for i 0 (1+ i) (eq? i 4)
(vector-set! mem i (make-vector (1+ size) (cons (random 23) (random 75)))))
(cycle
(for i 0 (1+ i) (eq? i 4)
(set! tmpmem (vector-ref mem i))
(set! tmppos (vector-ref pos i))
(when (and (eq? (car tmppos)
(car (vector-ref tmpmem size)))
(eq? (cdr tmppos)
(cdr (vector-ref tmpmem size))))
(vector-set! pos i (cons (random 23) (random 75)))
(set! tmppos (vector-ref pos i)))
(locate (car (vector-ref tmpmem 0))
(cdr (vector-ref tmpmem 0)) p)
(display #\space p)
(for j 0 (1+ j) (eq? j size)
(vector-set! tmpmem
j
(vector-ref tmpmem (1+ j))))
(set! tmp (copy (vector-ref tmpmem size)))
(cond ((< (car tmp) (car tmppos)) (set-car! tmp (1+ (car tmp))))
((> (car tmp) (car tmppos)) (set-car! tmp (-1+ (car tmp)))))
(cond ((< (cdr tmp) (cdr tmppos)) (set-cdr! tmp (1+ (cdr tmp))))
((> (cdr tmp) (cdr tmppos)) (set-cdr! tmp (-1+ (cdr tmp)))))
(locate (car tmp)
(cdr tmp) p)
(display #\* p)
(vector-set! tmpmem size tmp))))