News:

Function Finder  Find all the functions within source code files

Main Menu

very basic text question

Started by AndyD, January 14, 2011, 10:55:45 AM

Previous topic - Next topic

AndyD

I am having great fun with playbasic writing a really crude 3D game, but am having problems getting my head around writing text to the screen.

Coming from an old skool BASIC background I am used to using a character based display where printing at a location on the screen overwrites whatever was there. As you all know this would not be desireable in most Playbasic programmes.

Is there an easy way to show updating information on the screen without clearing the rest of the display?

Here is a code snippet to illustrate my problem:

for a=1 to 100
   text 100,100,a
   sync
   waitnokey
   waitkey
NEXT A

waitnokey
waitkey

Any thoughts?

Ta

Big C.

i would say... no

or you thought about a solution where you first clear the line and then you update your text... but I think thats not a good style...

have a look to the FAQ

there you will find that PB is using Double-Buffering... and I think its fast, very fast...  ;)

kevin

 
you could just clear that region..


for a=1 to 100
;   text 100,100,a
   itextb 100,100,a,00
   sync
   waitnokey
   waitkey
NEXT A



Psub iTextB(xpos,ypos,Message,backgroundcolour)
Message$=str$(Message)

xpos2=xpos+GetTextWidth(Message$)
ypos2=ypos+GetTextHeight(Message$)

boxc xpos,ypos,xpos2,ypos2,true,backgroundcolour
text xpos,ypos,message$

EndPsub



AndyD

Thanks Kevin, that's exactly what I was looking for.

;D