Snakes / worms
Posted: Thu Feb 12, 2015 10:13 pm
REM
REM worms/snakes v1.0
REM iPhone 6 plus / 8.3 b1
REM real quick in the parking lot.
graphics
'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
sn=5 'number of snakes
DIM x(sn+1),y(sn+1),k(sn+1),l(sn+1),c(sn+1),d(sn+1)
DIM x1(sn+1),x2(sn+1),x3(sn+1),x4(sn+1),x5(sn+1),x6(sn+1),x7(sn+1)
DIM x8(sn+1),x9(sn+1),x10(sn+1),x11(sn+1),x12(sn+1),x13(sn+1),x14(sn+1)
DIM x15(sn+1),x16(sn+1),x17(sn+1),x18(sn+1)
DIM x19(sn+1),x20(sn+1),x21(sn+1)
DIM y1(sn+1),y2(sn+1),y3(sn+1),y4(sn+1),y5(sn+1),y6(sn+1),y7(sn+1)
DIM y8(sn+1),y9(sn+1),y10(sn+1),y11(sn+1),y12(sn+1),y13(sn+1),y14(sn+1)
DIM y15(sn+1),y16(sn+1),y17(sn+1),y18(sn+1)
DIM y19(sn+1),y20(sn+1),y21(sn+1)
PI=3.1415
ang=PI/180
dc1 = 1
dc2 = 1
dc3 = 1
c1=100
c2=150
c3=200
FOR a=1 TO sn
c(a)=RND(scw)
d(a)=RND(sch)
NEXT a
'PRINT "done randomizing..."
loop:
refresh off
'graphics clear 0,0,0
vm=1-vm
'PAUSE 0.021
FOR a=1 TO sn
k(a)=l(a)
c1=c1+dc1 'red
c2=c2+dc2 'green
c3=c3+dc3 'blue
IF c1>255 OR c1 < 1 THEN
dc1=-dc1
END IF
IF c2>255 OR c2 < 1 THEN
dc2=-dc2
END IF
IF c3>255 OR c3 < 1 THEN
dc3=-dc3
END IF
worm:
l(a)=INT(RND(36))
IF l(a) > ABS(k(a)-34) AND l(a) < ABS(k(a)-2) THEN
GOTO worm
END IF
IF l(a) > ABS(k(a)+2) AND l(a) < ABS(k(a)+34) THEN
GOTO worm
END IF
x(a)=c(a)
y(a)=d(a)
IF x(a)>scw THEN
x(a)=0
'y(a)=RND(sch)
END IF
IF x(a)<0 THEN
x(a)=scw
END IF
IF y(a)>sch THEN
y(a)=0
END IF
IF y(a)<0 THEN
y(a)=sch
END IF
d(a)=SIN(8*l(a)*ang)*8+y(a)
c(a)=COS(8*l(a)*ang)*8+x(a)
x21(a)=x20(a)
x20(a)=x19(a)
x19(a)=x18(a)
x18(a)=x17(a)
x17(a)=x16(a)
x16(a)=x15(a)
x15(a)=x14(a)
x14(a)=x13(a)
x13(a)=x12(a)
x12(a)=x11(a)
x11(a)=x10(a)
x10(a)=x9(a)
x9(a)=x8(a)
x8(a)=x7(a)
x7(a)=x6(a)
x6(a)=x5(a)
x5(a)=x4(a)
x4(a)=x3(a)
x3(a)=x2(a)
x2(a)=x1(a)
x1(a)=x(a)
y21(a)=y20(a)
y20(a)=y19(a)
y19(a)=y18(a)
y18(a)=y17(a)
y17(a)=y16(a)
y16(a)=y15(a)
y15(a)=y14(a)
y14(a)=y13(a)
y13(a)=y12(a)
y12(a)=y11(a)
y11(a)=y10(a)
y10(a)=y9(a)
y9(a)=y8(a)
y8(a)=y7(a)
y7(a)=y6(a)
y6(a)=y5(a)
y5(a)=y4(a)
y4(a)=y3(a)
y3(a)=y2(a)
y2(a)=y1(a)
y1(a)=y(a)
'erase tail
fill COLOR 0,0,0
fill CIRCLE x21(a),y21(a) size 8
'head
fill COLOR 1,1,1
fill CIRCLE x1(a),y1(a) size 7
'draw
fill COLOR c1/255,c2/255,c3/255
fill CIRCLE x(a),y(a) size 7
NEXT a
refresh on
GOTO loop
REM worms/snakes v1.0
REM iPhone 6 plus / 8.3 b1
REM real quick in the parking lot.
graphics
'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
sn=5 'number of snakes
DIM x(sn+1),y(sn+1),k(sn+1),l(sn+1),c(sn+1),d(sn+1)
DIM x1(sn+1),x2(sn+1),x3(sn+1),x4(sn+1),x5(sn+1),x6(sn+1),x7(sn+1)
DIM x8(sn+1),x9(sn+1),x10(sn+1),x11(sn+1),x12(sn+1),x13(sn+1),x14(sn+1)
DIM x15(sn+1),x16(sn+1),x17(sn+1),x18(sn+1)
DIM x19(sn+1),x20(sn+1),x21(sn+1)
DIM y1(sn+1),y2(sn+1),y3(sn+1),y4(sn+1),y5(sn+1),y6(sn+1),y7(sn+1)
DIM y8(sn+1),y9(sn+1),y10(sn+1),y11(sn+1),y12(sn+1),y13(sn+1),y14(sn+1)
DIM y15(sn+1),y16(sn+1),y17(sn+1),y18(sn+1)
DIM y19(sn+1),y20(sn+1),y21(sn+1)
PI=3.1415
ang=PI/180
dc1 = 1
dc2 = 1
dc3 = 1
c1=100
c2=150
c3=200
FOR a=1 TO sn
c(a)=RND(scw)
d(a)=RND(sch)
NEXT a
'PRINT "done randomizing..."
loop:
refresh off
'graphics clear 0,0,0
vm=1-vm
'PAUSE 0.021
FOR a=1 TO sn
k(a)=l(a)
c1=c1+dc1 'red
c2=c2+dc2 'green
c3=c3+dc3 'blue
IF c1>255 OR c1 < 1 THEN
dc1=-dc1
END IF
IF c2>255 OR c2 < 1 THEN
dc2=-dc2
END IF
IF c3>255 OR c3 < 1 THEN
dc3=-dc3
END IF
worm:
l(a)=INT(RND(36))
IF l(a) > ABS(k(a)-34) AND l(a) < ABS(k(a)-2) THEN
GOTO worm
END IF
IF l(a) > ABS(k(a)+2) AND l(a) < ABS(k(a)+34) THEN
GOTO worm
END IF
x(a)=c(a)
y(a)=d(a)
IF x(a)>scw THEN
x(a)=0
'y(a)=RND(sch)
END IF
IF x(a)<0 THEN
x(a)=scw
END IF
IF y(a)>sch THEN
y(a)=0
END IF
IF y(a)<0 THEN
y(a)=sch
END IF
d(a)=SIN(8*l(a)*ang)*8+y(a)
c(a)=COS(8*l(a)*ang)*8+x(a)
x21(a)=x20(a)
x20(a)=x19(a)
x19(a)=x18(a)
x18(a)=x17(a)
x17(a)=x16(a)
x16(a)=x15(a)
x15(a)=x14(a)
x14(a)=x13(a)
x13(a)=x12(a)
x12(a)=x11(a)
x11(a)=x10(a)
x10(a)=x9(a)
x9(a)=x8(a)
x8(a)=x7(a)
x7(a)=x6(a)
x6(a)=x5(a)
x5(a)=x4(a)
x4(a)=x3(a)
x3(a)=x2(a)
x2(a)=x1(a)
x1(a)=x(a)
y21(a)=y20(a)
y20(a)=y19(a)
y19(a)=y18(a)
y18(a)=y17(a)
y17(a)=y16(a)
y16(a)=y15(a)
y15(a)=y14(a)
y14(a)=y13(a)
y13(a)=y12(a)
y12(a)=y11(a)
y11(a)=y10(a)
y10(a)=y9(a)
y9(a)=y8(a)
y8(a)=y7(a)
y7(a)=y6(a)
y6(a)=y5(a)
y5(a)=y4(a)
y4(a)=y3(a)
y3(a)=y2(a)
y2(a)=y1(a)
y1(a)=y(a)
'erase tail
fill COLOR 0,0,0
fill CIRCLE x21(a),y21(a) size 8
'head
fill COLOR 1,1,1
fill CIRCLE x1(a),y1(a) size 7
'draw
fill COLOR c1/255,c2/255,c3/255
fill CIRCLE x(a),y(a) size 7
NEXT a
refresh on
GOTO loop