TGC Codebase Backup



Fading bitmaps by Anonymous Coder

13th Oct 2004 22:39
Summary

Finds all "jpg" within the folder of the executable. Prints it on the screen. It adds the fading-out effect.



Description

Bugs :
1.Can't make fading effect start from a dark to a brighter effect.
2.Slow fading effect , even for Pentium 2.

Please post your tools or/and any plug-ins that we may install easily.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: bitmap
Rem Created: 12/10/2004 2:55:26 μμ

Rem ***** Main Source File *****

global files$
global file_name$
global fade_value = 100
global fade_operation$ = "decrease"
global state$="null"

dim files$(256)
dim filetypes(256)
dim sizes(256)
dim sizebytes(4)
dim offsets(256)
dim actualoffsets(4)
dim offsettemp(1)

file_number=0

`directory$=get dir$()
`print directory$
`wait key
directory$="C:\Program Files\Dark Basic Software\Dark Basic Professional\Internet codes\Various"
display()
get_file_name(directory$)
`findallfiles(directory$)
`load_bitmap(file_name$)
end


function load_bitmap(files$)
`file_name$="laetitia014.jpg"
fade_value = 100
fade_operation$ = "decrease"
set display mode 800, 600, 32 `1024,768,32
load bitmap files$ , file_number
do
fade bitmap bitmap_number , fade_value
if ( fade_operation$ = "decrease" ) then:fade_value= fade_value-15
if ( fade_operation$ = "increase" ) then:fade_value= fade_value+15
if ( fade_value < 20 ) then: fade_operation$ = "increase"
if ( fade_value > 100 ) then : fade_operation$ = "decrease"
if ( fade_value = 0 )then: exit
fastsync
loop

endfunction

`function bitmap_fading(bitmap_number , fade_value)
`fade bitmap bitmap_number , fade_value
`endfunction



function findallfiles(directory$)
foundfiles=0
`set dir directory$
`print directory$
find first
repeat
if get file type()=0 and get file name$() <> "bitmap.exe" and right$(get file name$(), 3) <> ""
   foundfiles=foundfiles+1
   files$(foundfiles)=get file name$()
   sizes(foundfiles)=file size(files$(foundfiles))
   filetypes(foundfiles)=0
endif
find next
until get file type()=-1
rem generate offsets
offsettemp(1)=8+(256*8)
for entries=1 to foundfiles
   offsets(entries)=offsettemp(1)
   offsettemp(1)=offsettemp(1)+(42+sizes(entries))
print files$(foundfiles)
   `load_bitmap( files$ )
next entries
wait key
endfunction

function get_file_name(directory$)
find first
repeat
if get file type()=0 and get file name$()<> "bitmap.exe"
   files$=get file name$()
   if right$(files$, 3) = "jpg" then : show_image(files$)`load_bitmap(files$) `print files$
endif
find next
until get file type()=-1
wait key
endfunction

function show_image(file_name$)
load bitmap file_name$ , file_number
`fade_bitmap()
print files$
do
`print current bitmap()
fade bitmap file_number , fade_value
if ( fade_operation$ = "decrease" ) then:fade_value= fade_value-15
if ( fade_operation$ = "increase" ) then:fade_value= fade_value+15
if ( fade_value < 0 ) then: fade_value=0 : fade_operation$ = "increase":exit
if ( fade_value > 100 ) then : fade_operation$ = "decrease"

fastsync
loop
fade_value=100:print "free"
`wait key
`cls
endfunction

function display()
set display mode 800, 600,32
endfunction



```````````````````````````
function fade_bitmap()
load bitmap file_name$ , file_number
do
`print current bitmap()
fade bitmap current bitmap() , fade_value
if ( fade_operation$ = "decrease" ) then:fade_value= fade_value-15
if ( fade_operation$ = "increase" ) then:fade_value= fade_value+15
if ( fade_value < 0 )   then: fade_value=100 : fade_operation$ = "increase":exit
if ( fade_value > 100 ) then: fade_operation$ = "decrease"
fastsync
loop
`wait key
endfunction