Code archives/3D Graphics - Misc/Fade in out

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

Download source code

Fade in out by Rook Zimbabwe2005
Code is not commented but if you have been playing with Blitz for more than a month you SHOULD get it... Use the Command Reference in Blitz to see what each part of the program does if you are unsure...

You are going to need an image (shown in startright) in png or jpg format with which to texture the sprite...
; fadein by Rook Zimbabwe
;
Graphics3D 800,600,16,1
SetBuffer BackBuffer()
AppTitle "FADER 1.0"

cam = CreateCamera()
PositionEntity cam,0,0,-10

Cls

startright=LoadTexture("image/TWSintro.png")

Global ghost
Global b#
Global flipper = CreateSprite()
EntityTexture flipper,startright

PositionEntity flipper,0,0,-8.5

oldtime = MilliSecs()
b#=0
ghost=1

While Not KeyHit (1)

Select ghost
	Case 1
		fadein()
	Case 0
		fadeout()
End Select

RenderWorld()

Text 0,12,"ALPHA: "+b#

Flip

Cls

Wend

End
; ########################### FUNCTIONS
;
; ########################### FADEIN
Function fadein()

If MilliSecs() > oldtime+1500 Then
b# = b# + .01
If b# > 1 Then 
	b# = 1
	ghost = 0
EndIf
EntityAlpha flipper,b#
oldtime = MilliSecs()

EndIf

End Function
; ########################### FADEOUT
Function fadeout()

If MilliSecs() > oldtime+1500 Then
b#=b#-.01
If b#<.001 Then 
	b#=0
	ghost = 1
EndIf
EntityAlpha flipper,b#
oldtime = MilliSecs()

EndIf

End Function
; ###########################

Comments

Rook Zimbabwe2005
Brilliant work... truly a work of genis... I am humbled... I am amazed... oh wait... I did this??? Hah! Should have commented it more...


Neochrome2005
LOL


Neochrome2005
LOL


Code Archives Forum