Author Topic: Grid Worm  (Read 1331 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 312
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Grid Worm
« on: October 23, 2021 »
Squares change colour with each move.

"Ctrl" key to see colour chart and count.

"End" key for random restart.

This might run fast.
I have one ready with 4x the squares.

Code: [Select]
size=1

restore rainbow
read col
dim R(col)
dim G(col)
dim B(col)
dim rgb$(col)
dim number(col)

for a=1 to col
read R(a)
read G(a)
read B(a)
read rgb$(a)
next a

if size=1 bar=320
if size=2 bar=1280
dim rise(bar)

for a=1 to bar
rise(a)=1
next a

if size=1 sel=150
if size=2 sel=660
s=ran(.2)+.4

y=0

sw=0

open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window

d=peek("port1")
if d<>1024 ctrl=1
if ctrl=1 ct=ct+1
if ct>2 ct=2
if ct=2 ctrl=0
if d=1024 ct=0

if ctrl=1 sw=sw+1
if sw>1 sw=0

if and(d,8192)>0 then
for a=1 to bar
rise(a)=1
next a
if size=1 sel=150
if size=2 sel=660
s=ran(.2)+.4
endif

if and(d,16)>0 then
for a=1 to bar
rise(a)=rise(a)+1
next a
endif

if and(d,32)>0 then
for a=1 to bar
if sel=a rise(a)=1
next a
endif

z=c
label restart
t=ran(1)
if t<.26 c=0
if t>.25 and t<s c=1
if t>s and t<.76 c=2
if t>.75 c=3

if c-z=2 goto restart
if c-z=-2 goto restart

if z=0 and size=1 sel=sel-20
if z=0 and size=2 sel=sel-40
if z=1 sel=sel+1
if z=2 and size=1 sel=sel+20
if z=2 and size=2 sel=sel+40
if z=3 sel=sel-1

if sel<0 and size=1 sel=sel+320
if sel<0 and size=2 sel=sel+1280
if sel>320 and size=1 sel=sel-320
if sel>1280 and size=2 sel=sel-1280

for a=1 to col
number(a)=0
next a

for a=1 to bar

if sel=a rise(a)=rise(a)+1
if rise(a)>16 rise(a)=1

for b=1 to col
if rise(a)=b number(b)=number(b)+1
next b

next a

y=0

for a=1 to bar

x=x+1

if size=1 then
if x>20 then
y=y+1
x=1
endif
endif

if size=2 then
if x>40 then
y=y+1
x=1
endif
endif

for b=1 to col
if rise(a)=b setrgb 1,R(b),G(b),B(b)
next b

if size=1 fill rectangle x*32-31,y*32-31 to x*32,y*32
if size=2 fill rectangle x*16-15,y*16-15 to x*16,y*16

next a

for a=1 to col

if sw=0 then
setrgb 1,0,0,0
if number(a)<10 space=20
if number(a)>9 and number(a)<100 space=10
if size=1 and number(a)>99 space=0
if size=2 and number(a)>99 and number(a)<1000 space=0
if size=2 and number(a)>999 space=-10
if size=1 text 20+space,a*32-14,str$(number(a))
if size=1 text 102,a*32-14,rgb$(a)
if size=2 text 20+space,a*16+12,str$(number(a))
if size=2 text 98,a*16+12,rgb$(a)
setrgb 1,R(a),G(a),B(a)
if size=1 fill rectangle 96,a*32 to 65,a*32-31
if size=2 fill rectangle 96,a*16+16 to 81,a*16+1
endif

next a

until (1=0)

label rainbow
data 16
data 256,256,256,"white"    rem 768
data 152,256,152,"mint"     rem 560
data 181,126,220,"lavender" rem 527
data 256,256,000,"yellow"   rem 512
data 256,112,112,"pink"     rem 480
data 128,128,128,"grey"     rem 384
data 079,105,198,"indigo"   rem 382
data 002,164,211,"cerulean" rem 377
data 128,224,000,"olive"    rem 352
data 256,064,000,"orange"   rem 320
data 220,020,060,"crimson"  rem 300
data 256,000,000,"red"      rem 256
data 000,000,256,"blue"     rem 256
data 000,256,000,"green"    rem 256
data 128,064,000,"brown"    rem 192
data 036,010,064,"violet"   rem 110

Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.