Drawling lines gradually query

BlitzMax Forums/BlitzMax Beginners Area/Drawling lines gradually query

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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.

Graphics 800,600,0 

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,800,250	' draw white line
DrawLine 0,350,800,350	' draw white line no. 2
Flip

While Not KeyHit(Key_escape)


Wend


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



Very nice, thanks alot Tom.