Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GRIDSIZE = 20
- SPEED = 0.01 'Lower # = Faster speed.
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' 0: Off, 1: Turn Left, 2: Turn Right.
- ' White and Black should not be off.
- ' Colors must be in order. (Red>Green>etc)
- ' If a color is off, it returns to white.
- WHITE = 1
- BLACK = 2
- RED = 1
- GREEN = 2
- BLUE = 1
- YELLOW = 2
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' Version 2: 6 colors, seconds counter, better loading information, and custom pattern settings.
- BCOLOR 75,75,75
- TCOLOR 255,0,255
- CLS tty
- PRINT "Loading...","• Size:",gridsize,"x",gridsize,"("+STR$(gridsize*gridsize)+" cells)"
- PRINT "Setting variables..."
- IF white=0 THEN
- white=1+(INT(RND*2))
- ENDIF
- IF black=0 THEN
- black=1+(INT(RND*2))
- ENDIF
- tick=0
- size2=GRIDSIZE
- size=size2*size2
- x=INT((size2+1)/2)
- y=INT((size2+1)/2) 'Start in middle
- d=2 'Direction. '1:Left,2:Up,3:Right,4:Dwn.
- DIM grid(size)
- COLOR 255,255,255
- CLS tty
- PRINT "Loading...","• Size:",gridsize,"x",gridsize,"("+STR$(gridsize*gridsize)+" cells)"
- PRINT "Generating array..."
- FOR i=1 TO size
- grid(i)=0 'Off/White: Background grid.
- NEXT
- CLS tty
- PRINT "Loading...","• Size:",gridsize,"x",gridsize,"("+STR$(gridsize*gridsize)+" cells)"
- PRINT "Drawing grid..."
- FOR i=1 TO size2
- FOR j=1 TO size2
- RRECT (i*(ScreenWidth/size2))-(ScreenWidth/size2),(j*(ScreenHeight/size2))-(ScreenHeight/size2),i*(ScreenWidth/size2),j*(ScreenHeight/size2),5
- NEXT
- NEXT
- SLEEP 0.01
- CLS tty
- t1=TickCount
- WHILE x>0 AND y>0 AND x<size2 AND y<size2
- tick=tick+1
- t2=TickCount
- PRINT tick,"•",STR$(INT(t2-t1))
- IF grid(x*y)=0 THEN 'If White.
- grid(x*y)=1 'Turn Black.
- COLOR 0,0,0
- d=d+(-3+(white*2)) 'Turn
- ELSE
- IF grid(x*y)=1 THEN 'If black
- IF red<>0 THEN
- grid(x*y)=2 'Turn red
- COLOR 255,0,0
- ELSE
- grid(x*y)=0 'Turn white
- COLOR 255,255,255
- ENDIF
- d=d+(-3+(black*2)) 'Turn
- ELSE
- IF grid(x*y)=2 THEN 'if red
- IF green<>0 THEN
- grid(x*y)=3 'Turn green
- COLOR 0,255,0
- ELSE
- grid(x*y)=0 'Turn white
- COLOR 255,255,255
- ENDIF
- d=d+(-3+(red*2)) 'Turn
- ELSE
- IF grid(x*y)=3 THEN 'if green
- IF blue<>0 THEN
- grid(x*y)=4 'Turn blue
- COLOR 0,0,255
- ELSE
- grid(x*y)=0 'Turn white
- COLOR 255,255,255
- ENDIF
- d=d+(-3+(green*2)) 'Turn
- ELSE
- IF grid(x*y)=4 THEN 'if blue
- IF yellow<>0 THEN
- grid(x*y)=5 'Turn yellow
- COLOR 255,255,0
- ELSE
- grid(x*y)=0 'Turn white
- COLOR 255,255,255
- ENDIF
- d=d+(-3+(blue*2)) 'Turn
- ELSE
- IF grid(x*y)=5 THEN 'if yello.
- grid(x*y)=0 'Turn white
- COLOR 255,255,255
- d=d+(-3+(yellow*2))
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- RRECT (x*(ScreenWidth/size2))-(ScreenWidth/size2),(y*(ScreenHeight/size2))-(ScreenHeight/size2),x*(ScreenWidth/size2),y*(ScreenHeight/size2),5
- IF d=0 THEN
- d=4
- ENDIF
- IF d=5 THEN
- d=1
- ENDIF
- IF d=1 THEN
- x=x-1
- ENDIF
- IF d=2 THEN
- y=y-1
- ENDIF
- IF d=3 THEN
- x=x+1
- ENDIF
- IF d=4 THEN
- y=y+1
- ENDIF
- SLEEP speed
- CLS tty
- WEND
- t3=TickCount
- PRINT STR$(tick),"ticks."
- PRINT STR$(INT(t3-t1)),"seconds."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement