The "closeScreen" function will allow you to add different screen transition effects to your programs. I've also included some other functions that are pretty useful too.
NOTE: Their are two versions for the "closeScreen" function; one for DBC, one for DBPRO.
Here's the functions:
drawSquare
function drawSquare(x, y, size)
dec size
if size > 0
box x, y, (x + size), (y + size)
else
dot x, y
endIf
endFunction
drawVerticalLine
function drawVerticalLine(x, y1, y2, lineWidth)
dec lineWidth
if lineWidth > 0
box x, y1, (x + lineWidth), y2
else
line x, y1, x, y2
endIf
endFunction
drawHorizontalLine
function drawHorizontalLine(y, x1, x2, lineWidth)
dec lineWidth
if lineWidth > 0
box x1, y, x2, (y + lineWidth)
else
line x1, y, x2, y
endIf
endFunction
drawHollowBox
function drawHollowBox(x1, y1, x2, y2, lineWidth)
drawVerticalLine(x1, y1, y2, lineWidth)
drawHorizontalLine(y2, x1, (x2 + (lineWidth - 1)), lineWidth)
drawVerticalLine(x2, y1, y2, lineWidth)
drawHorizontalLine(y1, x1, x2, lineWidth)
endFunction
closeScreen - DBC VERSION
function closeScreen(totalLoops, fromBottom, fromLeft, fromTop, fromRight, lineWidth, delay)
screenWidth = screen width() : screenHeight = screen height()
screenWidthHalf = (screenWidth / 2) : screenHeightHalf = (screenHeight / 2)
x1 = 0 : y1 = 0
x2 = screenWidth : y2 = screenHeight
for num = 0 to (totalLoops / lineWidth)
if fromBottom = 1 then drawHorizontalLine(y2, 0, (screenWidth - 1), lineWidth) : dec y2, lineWidth
if fromLeft = 1 then drawVerticalLine(x1, 0, (screenHeight - 1), lineWidth) : inc x1, lineWidth
if fromTop = 1 then drawHorizontalLine(y1, 0, (screenWidth - 1), lineWidth) : inc y1, lineWidth
if fromRight = 1 then drawVerticalLine(x2, 0, (screenHeight - 1), lineWidth) : dec x2, lineWidth
sync
if delay > 0 then wait delay
next num
endFunction
closeScreen - DBPRO VERSION
function closeScreen(totalLoops, fromBottom, fromLeft, fromTop, fromRight, lineWidth, delay)
screenWidth = screen width() : screenHeight = screen height()
screenWidthHalf = (screenWidth / 2) : screenHeightHalf = (screenHeight / 2)
x1 = 0 : y1 = 0
x2 = screenWidth : y2 = screenHeight
for num = 0 to (totalLoops / (lineWidth - 1))
if fromBottom = 1 then drawHorizontalLine(y2, 0, screenWidth, lineWidth) : dec y2, (lineWidth - 1)
if fromLeft = 1 then drawVerticalLine(x1, 0, screenHeight, lineWidth) : inc x1, (lineWidth - 1)
if fromTop = 1 then drawHorizontalLine(y1, 0, screenWidth, lineWidth) : inc y1, (lineWidth - 1)
if fromRight = 1 then drawVerticalLine(x2, 0, screenHeight, lineWidth) : dec x2, (lineWidth - 1)
sync
if delay > 0 then wait delay
next num
endFunction
NOTE: The "closeScreen" function uses BOTH the "drawHorizontalLine" and "drawVerticalLine" functions.
Here's my favorite use of the "closeScreen" function (DBC):
sync on : sync rate 60
cls rgb(255, 255, 255)
ink 0, 0
closeScreen(screen width() / 2, 0, 1, 1, 1, 5, 0)
ink rgb(255, 255, 255), 0
print "done." : sync
suspend for key
end
function drawSquare(x, y, size)
dec size
if size > 0
box x, y, (x + size), (y + size)
else
dot x, y
endIf
endFunction
function drawVerticalLine(x, y1, y2, lineWidth)
dec lineWidth
if lineWidth > 0
box x, y1, (x + lineWidth), y2
else
line x, y1, x, y2
endIf
endFunction
function drawHorizontalLine(y, x1, x2, lineWidth)
dec lineWidth
if lineWidth > 0
box x1, y, x2, (y + lineWidth)
else
line x1, y, x2, y
endIf
endFunction
function drawHollowBox(x1, y1, x2, y2, lineWidth)
drawVerticalLine(x1, y1, y2, lineWidth)
drawHorizontalLine(y2, x1, (x2 + (lineWidth - 1)), lineWidth)
drawVerticalLine(x2, y1, y2, lineWidth)
drawHorizontalLine(y1, x1, x2, lineWidth)
endFunction
function closeScreen(totalLoops, fromBottom, fromLeft, fromTop, fromRight, lineWidth, delay)
screenWidth = screen width() : screenHeight = screen height()
screenWidthHalf = (screenWidth / 2) : screenHeightHalf = (screenHeight / 2)
x1 = 0 : y1 = 0
x2 = screenWidth : y2 = screenHeight
for num = 0 to (totalLoops / lineWidth)
if fromBottom = 1 then drawHorizontalLine(y2, 0, (screenWidth - 1), lineWidth) : dec y2, lineWidth
if fromLeft = 1 then drawVerticalLine(x1, 0, (screenHeight - 1), lineWidth) : inc x1, lineWidth
if fromTop = 1 then drawHorizontalLine(y1, 0, (screenWidth - 1), lineWidth) : inc y1, lineWidth
if fromRight = 1 then drawVerticalLine(x2, 0, (screenHeight - 1), lineWidth) : dec x2, lineWidth
sync
if delay > 0 then wait delay
next num
endFunction
NOTE: Try adding some ink commands to the "closeScreen" function for some more cool effects.
Something like this: (DBC)
sync on : sync rate 60
cls rgb(255, 255, 255)
ink 0, 0
closeScreen(screen width() / 2, 0, 1, 1, 1, 5, 0)
ink rgb(255, 255, 255), 0
print "done." : sync
suspend for key
end
function drawSquare(x, y, size)
dec size
if size > 0
box x, y, (x + size), (y + size)
else
dot x, y
endIf
endFunction
function drawVerticalLine(x, y1, y2, lineWidth)
dec lineWidth
if lineWidth > 0
box x, y1, (x + lineWidth), y2
else
line x, y1, x, y2
endIf
endFunction
function drawHorizontalLine(y, x1, x2, lineWidth)
dec lineWidth
if lineWidth > 0
box x1, y, x2, (y + lineWidth)
else
line x1, y, x2, y
endIf
endFunction
function drawHollowBox(x1, y1, x2, y2, lineWidth)
drawVerticalLine(x1, y1, y2, lineWidth)
drawHorizontalLine(y2, x1, (x2 + (lineWidth - 1)), lineWidth)
drawVerticalLine(x2, y1, y2, lineWidth)
drawHorizontalLine(y1, x1, x2, lineWidth)
endFunction
function closeScreen(totalLoops, fromBottom, fromLeft, fromTop, fromRight, lineWidth, delay)
screenWidth = screen width() : screenHeight = screen height()
screenWidthHalf = (screenWidth / 2) : screenHeightHalf = (screenHeight / 2)
x1 = 0 : y1 = 0
x2 = screenWidth : y2 = screenHeight
for num = 0 to (totalLoops / lineWidth)
ink rgb(255, 0, 0), 0
if fromBottom = 1 then drawHorizontalLine(y2, 0, (screenWidth - 1), lineWidth) : dec y2, lineWidth
ink rgb(0, 255, 0), 0
if fromLeft = 1 then drawVerticalLine(x1, 0, (screenHeight - 1), lineWidth) : inc x1, lineWidth
ink rgb(0, 0, 255), 0
if fromTop = 1 then drawHorizontalLine(y1, 0, (screenWidth - 1), lineWidth) : inc y1, lineWidth
ink rgb(255, 255, 0), 0
if fromRight = 1 then drawVerticalLine(x2, 0, (screenHeight - 1), lineWidth) : dec x2, lineWidth
sync
if delay > 0 then wait delay
next num
endFunction
NOTE: To make those examples work for DBPRO just switch to the DBPRO version of the "closeScreen" function.
I've tested all the functions quite a bit, but still their may be some bugs hiding somewhere. If you spot any, then let me know. ENJOY!