the equations are totaly random
i just write some and test it thats all. with most equations it generates straight flashing line or dot or it iterates for smoe (short) time and then it ends with flashing dot in some place
here is new version:
keys 1,2,..,9,0,q,w,e,..,o,p
Rem Project: Unpredictable Worm
Rem Created: 2003-10-13 12:07:39
Rem By Mariusz Skowronski
Rem ***** Main Source File *****
set display mode 640, 480, 16
sync on: sync rate 0
global g_xPos as integer
global g_yPos as integer
global g_dir as integer
global g_bmpWidth as integer
global g_bmpHeight as integer
global dim g_program(255, 7) as integer
global g_scrPtr as dword
global g_addr as dword
rem I use this becouse my demo version of DBP has DarkBasic logo which couses some artifacts
g_bmpWidth = 500
g_bmpHeight = 400
rem this is set here only for cleariance
g_xPos = g_bmpWidth >> 1
g_yPos = g_bmpHeight >> 1
g_dir = 0
g_scrPtr = 0
g_addr = 0
rem use 1st efect
CreateWormProgram(1)
rem start
local char as string
local i as integer
rem main loop
do
lock backbuffer
g_scrPtr = get backbuffer ptr()
rem update screen every 200 iterations
for i = 0 to 200
g_addr = g_scrPtr + (g_yPos * screen width() + g_xPos)*4
color = rgbr(*g_addr)
g_dir = g_program(color, g_dir)
inc color, 4
*g_addr = (color << 16) || (color << 8) || (color)
select g_dir
case 0 : dec g_yPos: endcase : rem up
case 1 : dec g_yPos: inc g_xPos: endcase : rem up right
case 2 : inc g_xPos: endcase : rem right
case 3 : inc g_yPos: inc g_xPos: endcase : rem right down
case 4 : inc g_yPos: endcase : rem down
case 5 : inc g_yPos: dec g_xPos: endcase : rem down left
case 6 : dec g_xPos: endcase : rem left
case 7 : dec g_yPos: dec g_xPos: endcase : rem left up
endselect
if g_xPos < 0 then g_xPos = g_bmpWidth-1
if g_xPos >= g_bmpWidth then g_xPos = 0
if g_yPos < 0 then g_yPos = g_bmpHeight-1
if g_yPos >= g_bmpHeight then g_yPos = 0
next i
unlock backbuffer
sync
char = inkey$()
select char
case "1": CreateWormProgram(1): endcase
case "2": CreateWormProgram(2): endcase
case "3": CreateWormProgram(3): endcase
case "4": CreateWormProgram(4): endcase
case "5": CreateWormProgram(5): endcase
case "6": CreateWormProgram(6): endcase
case "7": CreateWormProgram(7): endcase
case "8": CreateWormProgram(8): endcase
case "9": CreateWormProgram(9): endcase
case "0": CreateWormProgram(10): endcase
case "q": CreateWormProgram(11): endcase
case "w": CreateWormProgram(12): endcase
case "e": CreateWormProgram(13): endcase
case "r": CreateWormProgram(14): endcase
case "t": CreateWormProgram(15): endcase
case "y": CreateWormProgram(16): endcase
case "u": CreateWormProgram(17): endcase
case "i": CreateWormProgram(18): endcase
case "o": CreateWormProgram(19): endcase
case "p": CreateWormProgram(20): endcase
endselect
loop
end
rem currently available 5 programms
function CreateWormProgram(program as integer)
local color, d as integer
randomize 100
for color = 0 to 255
for d = 0 to 7
select program
rem program 1
case 1: g_program(color, d) = int(rnd(7)): endcase
rem program 2
case 2: g_program(color, d) = int(sqrt(color*color)+d) mod 8 : endcase
rem program 3
case 3: g_program(color, d) = int(sqrt(color*color)-sqrt(color)+d) mod 8 : endcase
rem program 4
case 4: g_program(color, d) = int((color*color)/d +d) mod 8 : endcase
rem program 5
case 5: g_program(color, d) = int((color*color/10)+(d*d)+d) mod 8: endcase
rem program 6
case 6: g_program(color, d) = int((color*color/15)+sqrt(d*d)+d) mod 8: endcase
rem program 7
case 7: g_program(color, d) = int(sqrt(color*color)+sqrt(d*d)-sqrt(color)+d) mod 8: endcase
rem program 8
case 8: g_program(color, d) = int((color+21*d)/5) mod 8: endcase
rem program 9
case 9: g_program(color, d) = int(color+(d*d)) mod 8: endcase
rem program 10
case 10: g_program(color, d) = int((color*color)/sqrt(color*d)+color) mod 8: endcase
rem program 11
case 11: g_program(color, d) = int((color*color)+sqrt(color)+color) mod 8: endcase
rem program 12
case 12: g_program(color, d) = int(2*sqrt(color)/d+color+d) mod 8: endcase
rem program 13
case 13: g_program(color, d) = int(2*sqrt(color)/d+sqrt(color)+d) mod 8: endcase
rem program 14
case 14: g_program(color, d) = int(sqrt(color*d)+sqrt(color)) mod 8: endcase
rem program 15
case 15: g_program(color, d) = int(25*color/sqrt(d+6)+sqrt(d)) mod 8: endcase
rem program 16
case 16: g_program(color, d) = int(25*color*sqrt(d+5)+sqrt(d+2)) mod 8: endcase
rem program 17
case 17: g_program(color, d) = int(100*sin(color)+4*cos(d*12)+4) mod 8: endcase
rem program 18
case 18: g_program(color, d) = int((color/11)*d+rnd(15)) mod 8: endcase
rem program 19
case 19: g_program(color, d) = int(color/rnd(5)+d*rnd(3)) mod 8: endcase
rem program 20
case 20: g_program(color, d) = int(color/rnd(9)+d*rnd(8)) mod 8: endcase
case default: g_program(color, d) = int(rnd(7)): endcase
endselect
next d
next r
g_xPos = g_bmpWidth >> 1
g_yPos = g_bmpHeight >> 1
g_dir = 0
cls
endfunction