` Title: Mandelbrot Fractal Generator ` Author: Spooky ` Why?: For 20 line competition at www.thegamecreators.com ` Tested: DBPro with patch 5 ` Help: After each image drawn, zoom in with left mouse button ` dragging out a rectangular selection ` Tinker: Following variables can be tinkered with: ` s = pixel size : bigger numbers = blockier image but much quicker to draw ` i = maximum iterations : bigger numbers = more detailed fractal but slower ` Problems: After you zoom in about 7 times, everything goes blocky, this is ` because DBPro is no good with VERY small numbers s=1 : ` pixel size i=200 : ` number of iterations sync on sync rate 0 draw sprites first dim c(153) x1 as double float x2 as double float x3 as double float x4 as double float x5 as double float y1 as double float y2 as double float y3 as double float y4 as double float y5 as double float sw=screen width()-1 sh=screen height()-1 for f=1 to 153 read c(f) next f x1=-2 x2=2 y1=-2 y2=2 do change mouse 1 for y=0 to sh step s y3=y1+(y*(y2-y1)/sh) for x=0 to sw step s x3=x1+(x*(x2-x1)/sw) x4=x3 y4=y3 t=0 for m=0 to i x5=(x4*x4)-(y4*y4)+x3 y5=(x4*y4*2)+y3 if sqrt((x5*x5)+(y5*y5))>2 then t=(m mod 50)+1 : exit x4=x5 y4=y5 next m ink rgb(c(t*3+1),c(t*3+2),c(t*3+3)),0 box x,y,x+s,y+s next x sync next y get image 1,0,0,sw+1,sh+1,1 sprite 1,0,0,1 set sprite 1,0,0 change mouse 0 ink rgb(255,255,255),0 do if mouseclick()=1 mx=mousex() my=mousey() while mouseclick()=1 nx=mousex() ny=mousey() line mx,my,nx,my line nx,my,nx,ny line nx,ny,mx,ny line mx,ny,mx,my sync endwhile sync if abs(mx-nx)>10 and abs(my-ny)>10 and nx>mx and ny>my then exit endif loop delete sprite 1 x3=(x2-x1)/sw y3=(y2-y1)/sh x2=x1+(nx*x3) x1=x1+(mx*x3) y2=y1+(ny*y3) y1=y1+(my*y3) loop data 0,0,0,175,0,0,193,0,0,209,0,0,223,0,0,235,3,0,244,9,0,250,18,0,253,30,0,253,44,0,250,60,0,244,78,0,235,97,0,223 data 117,0,209,136,0,193,156,0,175,175,0,156,193,0,136,209,0,117,223,0,97,235,0,78,244,0,60,250,2,44,253,10,30,253,24,18 data 250,42,9,244,63,3,246,87,0,223,113,0,209,140,0,193,166,0,175,190,0,156,211,0,136,229,0,117,243,0,97,251,0,78,254,0,60 data 251,0,44,253,0,30,229,3,18,211,9,9,190,19,3,166,30,0,140,44,0,113,60,0,60,78,0,63,97,0,42,117,0,24,136,0,10,156,0,2