TGC Codebase Backup



Input function, replaces DBPro's input command by Orgull V2

4th Sep 2004 20:18
Summary

Variable font sizes, clear background (no underlines), functional backspace.



Description

Hi there.

After much anguish, my function finally works, and better than the DBPro "input" command. It does pause the program though, but it's better than nothing. It works with backspace and the background behind the text stays clean thanks to the background "box".

Just pass x,y, text color and background color and presto! It works with multiple font sizes too, which is good. If you don't want the input centered, then just replace "center text" with "text".

(I can't believe how long it took me to get this to work just right)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function inputtext(x,y,inputcolor,bkgcolor)

text$ = ""

do

current$ = inkey$()

if current$ = old$ then goto skip1

if scancode() <> 14
   if scancode() <> 28
      text$ = text$ + current$
      old$ = current$
   endif
endif

skip1:

   if scancode() = 14 then text$ = left$(text$,len(text$)-1):slow = 1
   if scancode() = 28 then goto out

ink bkgcolor,0
x1 = (x-(text width(text$)/2))-(text size()+1)
x2 = (x+(text width(text$)/2))+(text size()+1)
y1 = y-3
y2 = (y+text size()+3)

box x1,y1,x2,y2

ink inputcolor,0
set text opaque
center text x,y,text$

if slow = 1 then wait 150:slow = 0

loop

out:

endfunction text$