Drawling lines gradually query

BlitzMax Forums/BlitzMax Beginners Area/Drawling lines gradually query

DannyD(Posted 2005) [#1]
Hi,
I have the following code which draws a rectangle with two lines bordering it.I'd like the white lines to become visible gradually from left to right, something like a progress bar being displayed (0 to 100%).Any tips on how to achieve this ? Thanks in advance.




Tom Darby(Posted 2005) [#2]
An easy way to do this is to use variables in your DrawLine routine, and increment these variables every time you loop through your code. Here's a rudimentary example:



Graphics 800,600,0 

Local i:Float, speed:Float

i# = 0
speed# = 5.0	' increase this to speed the lines up; decrease to slow them down.

While Not KeyHit(Key_escape)

	Cls

	SetColor 0,160,0		' change color to green
	DrawRect 0,250,800,100	' draw green box
	
	SetColor 255,255,255	' change color to white
	DrawLine 0,250,i#,250	' draw white line
	DrawLine 0,350,i#,350	' draw white line no. 2
	Flip
	
	i# = i# + speed#
	
	If i# > 800 Then
		i# = 800
	EndIf

Wend




DannyD(Posted 2005) [#3]
Very nice, thanks alot Tom.