TGC Codebase Backup



Making A List Of Messages To Scroll Down The Screen by WhizzRich

13th May 2004 6:15
Summary

Simple adding of text which scrolls down the screen for easy reading.



Description

Allows for upto 10 lines of text, although the amount is very easy to change!

The textstaylength is how many game loops the text stays on the screen for, the higher the longer.

In the repeat loop I made it make a darkly coloured box, with the white text over it. There is a space of 30 pixels between the top of each box/text, which is plenty. However, if you wish to have a different space simply change each of the 30's to whatever you want. It is simple enough to understand.

One small glitch is that if you have 2 new lines of text appearing in the same game loop, the latter text will replace the original text. To get rid of this simply make the code a gosub, and after entering the new text call the gosub.
This will, however, decrease the length of time the text will stay on the screen. To remedy this, take out the textstay(a) = textstay(a)-1, and place it on it's own (with the repeat loop) outside the gosub. Easy!

Thanks,
Rich (WhizzRich)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    dim text$(10) : dim textstay(10)

textstaylength = 200

if text$(0) <> ""
   for a = 10 to 1 step -1
      text$(a) = text$(a-1)
      textstay(a) = textstay(a-1)
   next a
endif

text$(0) = ""

for a = 1 to 10
   textstay(a) = textstay(a)-1
   if textstay(a) > 0
      ink rgb(50,20,20),0
      box 0,(a*30)-30,text width(text$(a)),((a*30)-30)+text height(text$(a))
      ink rgb(255,255,255),0
      text 0,(a*30)-30,text$(a)
   endif
next a

`simply put this line in whenever you want a new line of text
text$(0) = "Text here." : textstay(0) = textstaylength