1 SRAND(0); COL=4; FN=INPUT("BMP file ? ")
2 FN:GONEXT;F=G_MAINIMG;W=H=120;GONEXT 2
3 (F,W,H)=GLOADIMAGE(FN);GCOPY(,,,,F);(W,H)/=(COL,COL)
4 GSCREEN(G_ENABLE, W*COL, H*COL, F); !FN:GOSUB DRAW
5 #
6 .SHUFFLE; (I0,I1) = (GALLOCIMAGE(W,H), GALLOCIMAGE(W,H))
7 LOOP I,16; (X0,Y0,X1,Y1)=(RAND(COL),RAND(COL),RAND(COL),RAND(COL))
8 GOSUB CHANGE, (X0,Y0,X1,Y1); WAIT 30; LOOPEND
9 X=0; Y=0; S=0; GOSUB DRAWBOX,(X,Y,G_WHITE)
10 #
11 .MAIN; WAIT 10; 0@GSCRSTAT()==G_DISABLE:END; K=GINKEY(); (K==""):GONEXT 0
12 (K!="q"):GONEXT; GSCREEN(G_DISABLE);END
13 GOSUB DRAWBOX,(X,Y,G_WHITE)
14 ((K=="LEFT" ) && (X>0)): X--; ((K=="RIGHT") && (X<COL-1)): X++
15 ((K=="UP"   ) && (Y>0)): Y--; ((K=="DOWN" ) && (Y<COL-1)): Y++
16 (K!=" "): GONEXT 3
17 S: GONEXT; S=1;SX=X;SY=Y;GOSUB DRAWBOX,(X,Y,G_RED);GONEXT 2
18 S=0;GOSUB DRAWBOX,(SX,SY,G_RED);GOSUB CHANGE,(X,Y,SX,SY)
19 GOSUB DRAWBOX,(X,Y,G_WHITE); GOTO MAIN
20 #
21 .CHANGE(X0+,Y0+,X1+,Y1+)
22 X0*=W;Y0*=H;X1*=W;Y1*=H
23 GCOPY(,,,,,X0,Y0,W,H,,I0); GCOPY(,,,,,X1,Y1,W,H,,I1)
24 GCOPY(X0,Y0,,,I1); GCOPY(X1,Y1,,,I0)
25 GFLUSH(G_SYNC); RETURN,(Y1-,X1-,Y0-,X0-)
26 #
27 .DRAWBOX(X+,Y+,C+)
28 X*=W;Y*=H; GBOX(X,Y,X+W-1,Y+H-1,C,G_FILL|G_XOR)
29 GFLUSH(G_SYNC); RETURN,(C-,Y-,X-)
30 #
31 .DRAW; NEW X,Y; LOOP N,5; (DEG0,DEG1)=(RAND(360),RAND(360))
32 D1 = RAND(12) @ (4,5,6,8,9,10,12,16,18,20,24,36)
33 (R0, R1) = (N * 50 + 40, RAND(60) + 10)
34 C = RAND(7) @ (G_BLUE,G_GREEN,G_CYAN,G_RED,G_MAGENTA,G_YELLOW,G_WHITE)
35 LOOP I, 360 + 1
36 (X,Y)  = (COS(RADIAN(DEG0 + I)) * R0, SIN(RADIAN(DEG0 + I)) * R0)
37 (X,Y) += (COS(RADIAN(DEG1    )) * R1, SIN(RADIAN(DEG1    )) * R1)
38 (I>0): GLINE(PX+W*2,PY+H*2,X+W*2,Y+H*2,C,G_OR)
39 (PX,PY)=(X,Y);DEG1+=D1;LOOPEND I;GFLUSH();LOOPEND;NEW X,Y;RETURN
