For some reason, when I run these three functions, it freezes up on me, randomly. The odd thing is, I have identified where it freezes, but it shouldn't be doing it. It happens in the hbox function, when the first set of for next loops completes, however it will not go past next s at all. I put in code to put s and v on the screen as well as the start and end values of each, showing that it only happens as soon as it completes. Oddly enough, even the CLI doesn't open when it freezes, making me thing maybe there is some sort of a glitch (or incompatibility with vista)
I tried to explain it as best as I can, but with my luck none of you will be able to make it happen, so here are the three functions:
function genmap()
for repeat=1 to 100
x#=rnd(100)
x#=x#/100
x=32*x#
y#=rnd(10)*10
y#=y#/100
y=32*y#
ink rgb(255,255,255),0
print repeat
sync
if repeat=30 or repeat=60 or repeat=90 or repeat=120 then cls
floodfill(x,y,1,0)
next repeat
endfunction
function hbox(x1,y1,x2,y2)
if x1>x2
temp=x1
x1=x2
x2=temp
endif
if y1>y2
temp=y1
y1=y2
y2=temp
endif
if x1<1 then x1=1
if y1<1 then y1=1
if y2>31 then y2=31
if x2>31 then x2=31
for s=y1 to y2
for v=x1 to x2
if v>=1 and s>=1 and s<=32 and v<=32
cls
print str$(s)+" "+str$(v)
print str$(x1)+" "+str$(y1)
print str$(x2)+" "+str$(y2)
sync
r=rnd(2)
if r=0
tile=2
endif
if r=1
tile=4
endif
if r=2
tile=3
endif
map(gmap(1),v,s)=tile
endif
next v
next s
repeat
until returnkey()=0
print hi
sync
`break
for y=y1+1 to y2-1
for x=x1+1 to x2-1
map(gmap(1),x,y)=1
next x
next y
cls
endfunction
function floodfill(x,y,fill,old)
if fill<>old
flag=0
if x<0 or x>32 then flag=1
if y<0 or y>32 then flag=1
if flag=0
color=map2(x,y)
if color<>fill
h=rnd(10)
w=rnd(10)
for a=x to x+w
for b=y-h to y+h
if b<0 then b=0
if b>40 then b=40
if a>40 then a=40
map2(a,b)=fill
next b
next a
hbox(x,y-h,x+w,y+h)
floodfill(x+w,y,fill,old)
floodfill(x-w,y,fill,old)
floodfill(x,int(y+h),fill,old)
floodfill(x,int(y-h),fill,old)
endif
endif
endif
` repeat
` until mouseclick()=0
set current bitmap 0
endfunction
This requires a few arrays to be created, here they are
map(40,40)
map2(40,40)
gmap(1) (set this to 1)
gmap is being used as a global constant, rather than re-writing all my functions and their calls to accept an extra parameter.
Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?