height = 10
width = 10
dim boxes(width, height)
sync on
sync rate 60
do
cls
rem trigger effect
if spacekey()
for y = 0 to height-1
for x = 0 to width-1
boxes(x,y) = 0
next x
next y
ax = 0
ay = 0
fade = 1
stamp = timer()
endif
rem do the effect
if fade = 1
for y = 0 to min(height-1, ay)
for x = 0 to min(width-1, ax-y)
boxes(x,y) = 1
next x
next y
ms = timer()
if stamp + 100 <= ms
inc ax
inc ay
if ax > width*2-1 then ax = width*2-1
if ay > height*2-1 then ay = height*2-1
stamp = ms
endif
endif
rem draw boxes
for y = 0 to height-1
for x = 0 to width-1
if boxes(x,y) = 1 then box x*17, y*17, x*17+16, y*17+16
next x
next y
sync
loop
Basically ax and ay carry on to twice the width/height, and then in the do-the-effect loop their values are taken and clamped at width/height to stop them going out the array.
edit: slightly optimised, only ax needs to go beyond limit.
height = 10
width = 10
dim boxes(width, height)
sync on
sync rate 60
do
cls
rem trigger effect
if spacekey()
for y = 0 to height-1
for x = 0 to width-1
boxes(x,y) = 0
next x
next y
ax = 0
ay = 0
fade = 1
stamp = timer()
endif
rem do the effect
if fade = 1
for y = 0 to ay
xMax = min(width-1, ax-y)
for x = 0 to xMax
boxes(x,y) = 1
next x
next y
ms = timer()
if stamp + 100 <= ms
inc ax
inc ay
if ax > width*2-1 then ax = width*2-1
if ay > height-1 then ay = height-1
stamp = ms
endif
endif
rem draw boxes
for y = 0 to height-1
for x = 0 to width-1
if boxes(x,y) = 1 then box x*17, y*17, x*17+16, y*17+16
next x
next y
sync
loop