Write text to screen by gearce22nd Dec 2006 0:17
|
---|
Summary This programme will write text to the screen one letter at a time Description This programme will write text to the screen one letter at a time Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` ------------------------------------------------------ ` Programme to write text to screen one letter at a time ` *********************** ` Author: gearce - December 2006 ` *********************** ` In this particular example, the message has it's ` centre in the middle of the screen, both horizontally ` and vertically, but can of course be positioned ` anywhere according to the values allocated to the ` variables across and down ` The speed at which the letters are written to the ` screen is determined by the delay value in the get ` letters subroutine ` Experiment with different font typefaces and sizes, ` across and down values, different number of message ` lines etc `------------------------------------------------------- ` This command will hide the mouse pointer hide mouse ` Messages a$="This is a programme to write text to the screen one" b$="letter at a time" c$="" d$=" Author: gearce - December 2006" e$="" f$="In this particular example, the message has 18 lines," g$="including blanks and is positioned in the middle of" h$="the screen, both horizontally and vertically, but can" i$="of course be positioned anywhere according to the" j$="values allocated to the variables across and down" k$="" l$="The speed at which the letters are written to the" m$="screen is determined by the delay value in the get" n$="letters subroutine" o$="" p$="Experiment with different font typefaces and sizes," q$="across and down values, different number of" r$="message lines, different delay values etc" ` Call text font function. Determine text height. Determine ` text width (i.e width of longest message line). Determine ` where to write text to screen. Set ink colour font_21(a$) th=text height("arial") tw=text width(f$) ` The value allocated to the down variable is determined ` by the number of lines in the message a=320-(tw/2):across=a:down=51 ink rgb(255,255,255),1 ` Go to subroutine to get letters from the messages message$=a$ gosub get_letters message$=b$ across=a:inc down,(th*1) gosub get_letters message$=c$ across=a:inc down,(th*1) gosub get_letters message$=d$ across=a:inc down,(th*1) gosub get_letters message$=e$ across=a:inc down,(th*1) gosub get_letters message$=f$ across=a:inc down,(th*1) gosub get_letters message$=g$ across=a:inc down,(th*1) gosub get_letters message$=h$ across=a:inc down,(th*1) gosub get_letters message$=i$ across=a:inc down,(th*1) gosub get_letters message$=j$ across=a:inc down,(th*1) gosub get_letters message$=k$ across=a:inc down,(th*1) gosub get_letters message$=l$ across=a:inc down,(th*1) gosub get_letters message$=m$ across=a:inc down,(th*1) gosub get_letters message$=n$ across=a:inc down,(th*1) gosub get_letters message$=o$ across=a:inc down,(th*1) gosub get_letters message$=p$ across=a:inc down,(th*1) gosub get_letters message$=q$ across=a:inc down,(th*1) gosub get_letters message$=r$ across=a:inc down,(th*1) gosub get_letters ` Wait forv a time before proceeding wait 1000 set cursor 0,460 print "Press any key to exit" ` Wait for user keypress suspend for key ` End of programme end ` --------------------------------------------- ` Subroutine to get letters from messages and ` write one at a time to screen ` --------------------------------------------- get_letters: long=len(message$) for z= 1 to long text across,down,left$(message$,(long-(long-z))) next z ` Determine the speed at which the letters are written delay=0 return ` ------------------------------------------------------------- ` Text font functions ` ------------------------------------------------------------- function font_21(a$) set text font "arial" set text size 21 set text to bold endfunction |