Why do my boxes keep vanishing? This used to work in DB Classic.
set display mode 1024,768,32
Randomize timer()
sync on
sync rate 60
hide mouse
Load Image "cursor.bmp",1
Dim Area(3000,4)
Current = 1
MaxWidth = 1024
MaxHeight = 768
Backcol1 = 255 : Backcol2 = 255 : Backcol3 = 0
cls rgb(Backcol1,backcol2,backcol3)
color backdrop 0
X = 0
Y = 0
Sprite 1,X,Y,1
CentreX=Sprite Width(1)/2: CentreY = Sprite Height(1)/2
Offset sprite 1,CentreX,CentreY
Propogate = 6
`set current bitmap 1
Do
If propogate > 5
Limit = rnd((Maxwidth+Maxheight)/200)+3
For n = 1 to Limit
X = rnd(Maxwidth)
Y = rnd(Maxheight)
If x + 70 > Maxwidth then X = 0 : inc Y,25
Width = rnd(40) : inc Width,30
If x + width > Maxwidth then X = 0 : inc Y,25
Height = (Width + 9) - rnd(5)
Gosub Collision_Check
If Col <> 1
`Hue = rnd(255)+1
Hue = 100
Box X,Y,X+Width,Y+Height,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Box X+10,Y+10,X+Width-10,Y+Height-10,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Area(Current,1) = X
Area(Current,2) = Y
Area(Current,3) = X+Width
Area(Current,4) = Y+Height
inc Current
EndIf
X = X + Width + Rnd(10) + 2
Col = 0
Next n
Limit = rnd((Maxwidth+Maxheight)/200)+3
For n = 1 to Limit
X = rnd(Maxwidth)
Y = rnd(Maxheight)
If x + 50 > Maxwidth then X = 0 : inc Y,25
Width = rnd(20) : inc Width,30
If x + width > Maxwidth then X = 0 : inc Y,25
Height = (Width + 9) - rnd(5)
Gosub Collision_Check
If Col <> 1
Hue = rnd(255)+1
Box X,Y,X+Width,Y+Height,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Box X+5,Y+5,X+Width-5,Y+Height-5,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Area(Current,1) = X
Area(Current,2) = Y
Area(Current,3) = X+Width
Area(Current,4) = Y+Height
inc Current
EndIf
X = X + Width + Rnd(10) + 2
Col = 0
Next n
Limit = rnd((Maxwidth+Maxheight)/200)+3
For n = 1 to Limit
X = rnd(Maxwidth)
Y = rnd(Maxheight)
If x + 50 > Maxwidth then X = 0 : inc Y,25
Width = rnd(20) : inc Width,30
If x + width > Maxwidth then X = 0 : inc Y,25
Height = (Width + 9) - rnd(5)
Gosub Collision_Check
If Col <> 1
Hue = rnd(255)+1
Box X,Y,X+Width,Y+Height,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Box X+5,Y+5,X+Width-5,Y+Height-5,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
OffsetXY = rnd(5)+6
Box X+(5+OffsetXY),Y+(5+OffsetXY),X+((Width-5)-OffsetXY),Y+((Height-5)-OffsetXY),RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Area(Current,1) = X
Area(Current,2) = Y
Area(Current,3) = X+Width
Area(Current,4) = Y+Height
inc Current
EndIf
X = X + Width + Rnd(10) + 2
Col = 0
Next n
X = 0
Y = 0
Endif
If Propogate > 0
Repeat
If x + 20 > Maxwidth then X = 0 : inc Y,25
Width = rnd(10+(Propogate*2)) : inc Width,5 + (Propogate * 2)
Height = (Width + 9) - rnd(5)
Gosub Collision_Check
If Col <> 1
Hue = rnd(255)+1
Box X,Y,X+Width,Y+Height,RGB(Hue,Hue,Hue),RGB(255,255,255),RGB(Hue,Hue,Hue),RGB(255,255,255)
sync
Area(Current,1) = X
Area(Current,2) = Y
Area(Current,3) = X+Width
Area(Current,4) = Y+Height
inc Current
EndIf
X = X + Width + Rnd(10) + 2
Col = 0
Until Y + 18 > MaxHeight
EndIf
Dec Propogate
Y = 0 + (20 - (Propogate*10))
X = 0
If propogate = 0
Hide sprite 1
get image 1,0,0,1024,768
Save image "Square Texture.bmp",1
Endif
sync
Loop
`******************************************************************
Collision_Check:
BoxX = (Width /2) + X
BoxY = (Height /2) + Y
Sprite 1,boxX,boxY,1
Gosub Areacheck
If Col<>1
Sprite 1,boxX,boxY+3,1
Gosub Areacheck
EndIf
If Col<>1
Sprite 1,boxX,boxY-3,1
Gosub Areacheck
EndIf
If Col<>1
Sprite 1,boxX+3,boxY,1
Gosub Areacheck
EndIf
If Col<>1
Sprite 1,boxX-3,boxY,1
Gosub Areacheck
EndIf
If Col<>1
BoxX = X
BoxY = Y
Repeat
Sprite 1,boxX,boxY-2,1
Inc BoxX,4
Gosub Areacheck
Until BoxX >= X+Width+2 or Col=1
Repeat
Sprite 1,boxX+2,boxY,1
Inc BoxY,4
Gosub Areacheck
Until BoxY >= Y+Height+2 or Col=1
Repeat
Sprite 1,boxX,boxY+2,1
Dec BoxX,4
Gosub Areacheck
Until BoxX <= X-2 or Col=1
Repeat
Sprite 1,boxX-2,boxY,1
Dec BoxY,4
Gosub Areacheck
Until BoxY <= Y-2 or Col=1
Endif
Return
AreaCheck:
For BoxCheck = 1 to Current
A = Area(BoxCheck,1)
B = Area(BoxCheck,2)
C = Area(BoxCheck,3)
D = Area(BoxCheck,4)
if OverBox(A,B,C,D)=1
Col = 1
endif
Next BoxCheck
Return
function OverBox(X1,Y1,X2,Y2)
J=0:ZX=Sprite x(1):ZY=Sprite y(1)
if ZX>=X1 and ZX<=X2 and ZY>=Y1 and ZY<=Y2 then J=1
endfunction J
