Weekly Qbasic and Qb64 Lesson Topics

TUTORIALS => QB64 Tutorials => Topic started by: GarrisonRicketson on April 08, 2012, 11:56:25 pm



Title: Makeing a "Splash Screen"
Post by: GarrisonRicketson on April 08, 2012, 11:56:25 pm
 I put this together,
Down Load, for  (http://dl.dropbox.com/u/15387474/A_SCREENSPLASH_tut.bas.zip) the .bas Demo, on makeing a "splash screen" or Screen "splash image",..
 Hoping some one finds it usefull, I sure did, with very much thanks, to Galleon, Terrie Richie, ,"Clippy", and others at  http://www.qb64.net (http://www.qb64.net)
 If you do need any further explanation, feel free to ask here, or follow the link included in the tutorial. it is a link to the entire discussion thread.
http://www.qb64.net/forum/index.php?topic=5816.msg59907#msg59907 (http://www.qb64.net/forum/index.php?topic=5816.msg59907#msg59907)
from Garry


Title: Re: Makeing a "Splash Screen"
Post by: GarrisonRicketson on April 09, 2012, 09:54:53 pm
It is pretty simple to do this now, with this utility: Written by Terrie Richie, also using Code contributed by Galleon,(the author of qb64 ) at qb64.net
Code:

'*************************
'* SPLASH SCREEN CREATOR *
'*************************
'

DIM strdata$
DIM filename$
DIM splashfile$
DIM count&
DIM outputfile$
DIM yesno$

strdata$ = ""
CLS
PRINT "SPLASH SCREEN CREATOR"
PRINT
PRINT "Enter file name of image to convert."
PRINT "(enter nothing to quit)"
PRINT
LINE INPUT "> "; filename$
IF filename$ = "" THEN END
IF NOT _FILEEXISTS(filename$) THEN
    PRINT
    PRINT "FILE NOT FOUND!"
    END
END IF
PRINT
PRINT "Enter file name of output (ex: splash1.bas)"
PRINT "(enter nothing to quit)"
PRINT
LINE INPUT "> "; outputfile$
IF outputfile$ = "" THEN END
PRINT
PRINT "Include QB64 viewer code in output?"
PRINT "(Y = include viewing code)"
PRINT "(N = just output the string data)"
PRINT
DO
    LINE INPUT "(Y/N)> "; yesno$

    yesno$ = LEFT$(UCASE$(yesno$), 1)
LOOP UNTIL yesno$ = "Y" OR yesno$ = "N"
PRINT
PRINT "Creating "; outputfile$; "... one moment please"
IF INSTR(filename$, ".") THEN
    splashfile$ = LEFT$(filename$, INSTR(filename$, ".") - 1) + RIGHT$(filename$, LEN(filename$) - INSTR(filename$, "."))
ELSE
    splashfile$ = filename$
END IF
OPEN outputfile$ FOR OUTPUT AS #2
IF yesno$ = "Y" THEN
    PRINT #2, "'************************"
    PRINT #2, "'* SPLASH SCREEN VIEWER *"
    PRINT #2, "'************************"
    PRINT #2, ""
    PRINT #2, "DIM "; splashfile$; "$"
    PRINT #2, "DIM byte~%%"
    PRINT #2, "DIM count&"
    PRINT #2, "DIM splash&"
    PRINT #2, "DIM "; splashfile$; "_bin$"
    PRINT #2, ""
END IF
PRINT #2, splashfile$; "$ = "; CHR$(34);
OPEN filename$ FOR BINARY AS #1
strdata$ = SPACE$(LOF(1))
GET #1, , strdata$
CLOSE #1
FOR count& = 1 TO LEN(strdata$)
    PRINT #2, RIGHT$("0" + HEX$(ASC(strdata$, count&)), 2);
NEXT count&
PRINT #2, CHR$(34)
IF yesno$ = "Y" THEN
    PRINT #2, ""
    PRINT #2, splashfile$; "_bin$ = SPACE$(LEN("; splashfile$; "$) \ 2)"
    PRINT #2, "FOR count& = 1 TO LEN("; splashfile$; "_bin$)"
    PRINT #2, "    ASC("; splashfile$; "_bin$, count&) = VAL("; CHR$(34); "&H"; CHR$(34); " + MID$("; splashfile$; "$, (count& - 1) * 2 + 1, 2))"
    PRINT #2, "NEXT count&"
    PRINT #2, "OPEN "; CHR$(34); "splash_"; filename$; CHR$(34); " FOR BINARY AS #1"
    PRINT #2, "PUT #1, , "; splashfile$; "_bin$"
    PRINT #2, "CLOSE #1"
    PRINT #2, ""
    PRINT #2, "splash& = _LOADIMAGE("; CHR$(34); "splash_"; filename$; CHR$(34); ", 32)"
    PRINT #2, "SCREEN splash&"
    PRINT #2, "_DELAY 5"
    PRINT #2, "SCREEN _NEWIMAGE(640, 480, 32)"
    PRINT #2, "KILL "; CHR$(34); "splash_"; filename$; CHR$(34)
    PRINT #2, "_FREEIMAGE splash&"
    PRINT #2, "PRINT "; CHR$(34); "CONTINUE YOUR PROGRAM HERE"; CHR$(34)
END IF
CLOSE #2
PRINT
PRINT outputfile$; " has been successfully created."
PRINT "NOW all you need do is compile the .bas file you just created!"
 

Then put it at the start of your program,if there are any questions , feel free to ask.