Jelly

By Cclx33

REM modify Davey W. Taylor’s QB code

DISPLAY 4
LAYER OPEN 0,128,128,0

DIM XP(27),YP(27),XV(27),YV(27),NX(27),NY(27),RD(27,27),FLR(200)

REM FLOOR
FOR X=0 TO 127
FLR(X)=95+SIN(X/15)*6+COS(X/6)*2
NEXT

REM SET NODES
SZ=12
FOR N=0 TO 27
XP(N)=(N MOD 7)*SZ+5
YP(N)=INT(N/7)*SZ+30
NEXT

FOR I=1 TO 11
READ A,B
GOSUB RELATE
NEXT
DATA 0,6,7,13,14,20,21,27,0,21,1,22,2,23,3,24,4,25,5,26,6,27

A=0
FOR Y=0 TO 3
FOR X=0 TO 6
B=A+1
IF X<6 THEN GOSUB RELATE
B=A+8
IF X<6 AND Y<3 THEN GOSUB RELATE
B=A+7
IF Y<3 THEN GOSUB RELATE
B=A+6
IF X>0 AND Y<3 THEN GOSUB RELATE
A=A+1
NEXT
NEXT

REM FACTORS
READ DFAC,FFAC,VFAC
DATA 0.6, 150, 1.1

DO
REM GRAVITY
FOR N=0 TO 27
YV(N)=YV(N)+0.02
NEXT

REM ‘CALCULATE AVERAGE FORCE
FOR N=0 TO 27
XFORCE=0
YFORCE=0
FOR R=0 TO 27
IF RD(N,R)>0 THEN
DD=(SQR((XP(N)-XP(R))^2+(YP(N)-YP(R))^2)-RD(N,R))/DFAC
XFORCE=XFORCE-(XP(N)-XP(R))*DD
YFORCE=YFORCE-(YP(N)-YP(R))*DD
END IF
NEXT
XV(N)=XV(N)+XFORCE/FFAC
YV(N)=YV(N)+YFORCE/FFAC

REM NEW NODE
NX(N)=XP(N)+XV(N)*VFAC
NY(N)=YP(N)+YV(N)*VFAC
IF NX(N)<0 THEN XV(N)=0.9
IF NX(N)>127 THEN XV(N)=-0.9
IF NY(N)<0 THEN YV(N)=0.9
X=MIN(MAX(INT(NX(N)),0),127)
IF NY(N)>=FLR(X)-1 THEN
NY(N)=FLR(X)-2
XV(N)=XV(N)-(FLR(X)-FLR((X+1) MOD 127))
YV(N)=-0.9
END IF
NEXT

FOR N=0 TO 27
XP(N)=NX(N)
YP(N)=NY(N)
NEXT

CLS

REM ‘DRAW NEW BLOCK
COLOR 7
RESTORE RELATE
FOR I=1 TO 18
READ A,B
LINE NX(A),NY(A) TO NX(B),NY(B)
NEXT

REM MOVE FLOOR
FLRM=FLR(0)
FOR X=0 TO 127
IF X<127 THEN FLR(X)=FLR(X+1) ELSE FLR(X)=FLRM
COLOR 8
PLOT X,FLR(X)
COLOR 0
LINE X,FLR(X)+1 TO X,127
NEXT
WAIT 0
LOOP

RELATE:
D=SQR((XP(A)-XP(B))^2+(YP(A)-YP(B))^2)
RD(A,B)=D
RD(B,A)=D
RETURN
DATA 0,1,1,2,2,3,3,4,4,5,5,6,6,13,13,20,20,27,27,26,26,25,25,24,24,23,23,22,22,21,21,14,14,7,7,0

Get LowRes Coder to use this program.

Play homegrown retro games and program your own!