18 lines
883 B
Text
18 lines
883 B
Text
include c:\cxpl\codes; \intrinsic 'code' declarations
|
|
def W=128, H=W; \width and height of field
|
|
int X, Y;
|
|
[SetVid($13); \set 320x200 graphic video mode
|
|
Point(W/2, H/2, 6\brown\); \place seed in center of field
|
|
loop [repeat X:= Ran(W); Y:= Ran(H); \inject particle
|
|
until ReadPix(X,Y) = 0; \ in an empty location
|
|
loop [Point(X, Y, 6\brown\); \show particle
|
|
if ReadPix(X-1,Y) or ReadPix(X+1,Y) or \particle collided
|
|
ReadPix(X,Y-1) or ReadPix(X,Y+1) then quit;
|
|
Point(X, Y, 0\black\); \erase particle
|
|
X:= X + Ran(3)-1; \(Brownian) move particle
|
|
Y:= Y + Ran(3)-1;
|
|
if X<0 or X>=W or Y<0 or Y>=H then quit; \out of bounds
|
|
];
|
|
if KeyHit then [SetVid(3); quit]; \restore text mode
|
|
];
|
|
]
|