Code archives/Graphics/TextFader()

This code has been declared by its author to be Public Domain code.

Download source code

TextFader() by n8r2k
(Posted 22 years ago)
Not sure if anyones done sometin like this so feel free to use this code anyway you like
Click here to download current versions of all my codes and games including this one: http://n8r2k.deviousbytes.com/
Graphics 800,600,16,2
Global g = 0
Global r = 155
Global bigfont = LoadFont("Arial",50,0,0,0)

While Not KeyHit(1)
ClsColor 155,0,0
Cls
textfader()
SetFont bigfont
Color r,g,0
Text 100,100,"Press space to fade in again"		;Edit this line
If KeyHit(57) resettext()
Flip
Wend

Function TextFader()
g = g + 1
r = r - 1
If r < 0
	r = 0
EndIf
If g > 128
	g = 128
EndIf
End Function

Function ResetText()
g = 0
r = 155
End Function

Comments

n8r2k
(Posted 22 years ago)
In case you were wondering, variables r and g can be messed with and you can even try adding a blue variable

Mortifer Nex
(Posted 19 years ago)
I cleaned up the code a bit, now it doesn't do any of TextFader if it's already done fading, it doesn't set the font every time you loop, and it doesn't set the ClsColor every time you loop. =D

Graphics 800,600,16,2
Global g = 0
Global r = 155
Global stopwriting=0
Global bigfont = LoadFont("Arial",50,0,0,0)
SetFont bigfont
ClsColor 155,0,0
While Not KeyHit(1)
Cls
textfader()
Color r,g,0
Text 100,100,"Press space to fade in again"
If KeyHit(57) resettext()
Flip
Wend 

Function TextFader()
If stopwriting >< 1
g = g + 1 
r = r - 1 
If r < 0 
	r = 0 
EndIf
If g > 128 
	stopwriting = 1
EndIf
EndIf
End Function 

Function ResetText() 
g = 0 
r = 155
stopwriting=0
End Function


It also doesn't blink anymore, as far as I'm aware.

Code Archives Forum