BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"2D Fast Fade"
, by waroffice
I made a file to fade out my levels in my RPG and found it could be usefull to others.
Any problems PM me
Code
;///////////////// ;fade version 1.0 ;///////////////// ;----------------- ;----- HELP ------ ;----------------- ; To use just put include "fade.bb" in your prog ; and to activate use the fade() function EG: ; if keyhit(57) then ;If space is pressed ; fade() ; End if Global fadeval,fadeimage,tmpimage Function FadeScreen() Color 0,0,0 ; Sets fade color (Default Black) While (fadeval<32) And (fadeval>-2) ; Each tile is 32x32 this is the part that checks which side of 0 and 32 the line is on SetBuffer ImageBuffer(fadeimage) ; Makes it draw to a image rather than the screen Line 0,fadeval,31,fadeval ; draws a line on the image from x=0 to x=31 where y=fadeval SetBuffer BackBuffer() ; returns drawing to screen DrawImage tmpimage,0,0 ; draws the pre-fade screen back to the screen TileImage fadeimage ; then draws the fade tile, tiled over the entire screen (tweak for custom position) Flip ;False ;draw everything change to run as fast as possible and not a monitor refresh fadeval=fadeval+1 ; add 1 to y position Wend fadeval=-2 ; when finished put y value out of range of loop End Function Function fade() fadeval=0 ; reset y value tmpimage=CreateImage(800,600) ; make a copy of the current screen - change resolution to fit your game (800,600) CopyRect 0,0,800,600,0,0,FrontBuffer(),ImageBuffer(tmpimage) ; same here (800,600) fadeimage=CreateImage(32,32) ; setup the fade tile SetBuffer ImageBuffer(fadeimage) ;Makes it draw to a image rather than the screen Color 255,0,255 ;sets colour To a unused colour for mask Rect 0,0,32,32,1 ;fill in tile with mask colour MaskImage fadeimage,255,0,255 ; mask it out fadescreen() ; run the fade bit End Function
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations