forums

TNT Basic Forums > Programming Q&A
Need some help with procedurs
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-08-2002 23:00

Posted by:
Chofritz

Find more posts by Chofritz

A few years ago I was programming a game (RPG) in quickbasic for pc. After doing the main things like battle engines and map system I stoped working on it.

However yesterday I found this site by an accident and I think I'll start working on a new RPG for mac. This TNT basic is almost the same language as Quickbasic so I guess I have some of my skills left, :)

Well no my main question. Everytime I use the command print the program jupms out of graphic mode 640x480 and some kind of text mode pops up. Is there a way to use the print command without this happening? If there isn't I think I'll use sprites as letters and numbers. But then I need a good way to program that since I can't write a specific peice of code for every sentance in the game. In quickbasic the were something called subs (Almost the same as procedurs). They were usefull. A print text sub could look something like this (this is not real code as you can see):

SUB PrintText (x, y, c, text)

x and y tells where to put the text, c is the text color and text is the text to write

The sub handels the numbers and puts the font sprite in the right location. Tada, your text is written exactly where you want it.

Everytime you wanted to use this you just had to write

PrintText 20, 20, 4, "Monkey eats banana"

Or whatever you wanted to write. That was very usefull. Is there a way to use procedurs the same way? I searched in the helpfile but found no info on this.

Any help would be appreciated, thanks!

If something is unclear please ask and I'll try to explain it better.

02-09-2002 06:05

Posted by:

Find more posts by

You need to use the Draw Text command.

Check the "TNT Basic Help" menu in Heiroglyph. Then clich the "Drawing" link on the left.

This will show you a list on the right look at the "Draw Text", "Text Font", "Text Size" and "Text Face" items. Oh, and if you want to change the color make sure to use "Set Pen Color"

The "Draw Text" command is written like this:

Draw Text x, y, "String of text"

Say you want to print the words "Hello to all my peeps in Doylestown" on the screen at coordinates 300,400 in the color red using the font Arial at the size of 18 and bold.

You do:

Set Pen Color Make Color(255,0,0)
Text Size 18
Text Face 1
Text Font "Arial"
Draw Text 300, 400, "Hello to all my peeps in Doylestown"

Hope that helped.

02-09-2002 06:05

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

You need to use the Draw Text command.

Check the "TNT Basic Help" menu in Heiroglyph. Then clich the "Drawing" link on the left.

This will show you a list on the right look at the "Draw Text", "Text Font", "Text Size" and "Text Face" items. Oh, and if you want to change the color make sure to use "Set Pen Color"

The "Draw Text" command is written like this:

Draw Text x, y, "String of text"

Say you want to print the words "Hello to all my peeps in Doylestown" on the screen at coordinates 300,400 in the color red using the font Arial at the size of 18 and bold.

You do:

Set Pen Color Make Color(255,0,0)
Text Size 18
Text Face 1
Text Font "Arial"
Draw Text 300, 400, "Hello to all my peeps in Doylestown"

Hope that helped.

02-09-2002 06:06

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Sorry. I forgot my name the first time. Hehehe.. Wish we could edit our posts.

02-09-2002 06:12

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

Oh, and the way you accept variables passed from Procedures is:

Procedure ProcName (Int variable1, Str variable2)

...

End Proc

Of course you can have all the variables passed into it as possible. Use Int for numbers, String for text and Float for numbers with decimal points.

Your example would be:

Procedure PrintText (Int x, Int y, Int c, String text)

...

End Proc

Then just call it:

PrintText (20, 20, 4, "Monkey eats banana")

02-09-2002 14:39

Posted by:
Chofritz

Find more posts by Chofritz

Thanks, ;)

Thanks, I figured out some of it myself, but that was great help!

02-09-2002 23:11

Posted by:
Chofritz

Find more posts by Chofritz

Something is wrong

I have a new problem now. I tried to use the draw text command but all I get is a black screen, :( Can someone please post an example that includes this command and gives something else than a black screen? Actually none of the draw commands I have tried works, :(

02-09-2002 23:34

Posted by:
Jason Anderson

Click Here to Email Jason Anderson   Find more posts by Jason Anderson

First make sure you set your game up for graphics mode.

_______________
Graphics Mode 640, 480
Set Framerate 60
Vbl Sync On
_______________

Of course yu can use whatever resolution you want and framerate. I use 60 as default.

Now.. make sure when you're drawing your text you specify the color to use. I think by default the Pen Color is set to black as the screen is too.

So do

________________
Set Pen Color Make Color (255,255,255)
Draw Text x, y, "Text to draw"
________________

Of course you can replace the Make Color (255,255,255) with whatever color you want. And the "Text to draw" with your text. And the x and y with the coordinates.

If this did not answer your question, post some code we can look at to see if something's wrong.

02-10-2002 10:00

Posted by:
Charles

Click Here to Email Charles   Find more posts by Charles

Draw Frame

You have to use the Draw frame command to tell TNT to actually put things onto the screen ; )

02-10-2002 23:54

Posted by:
Mark Tully

Find more posts by Mark Tully

..and if you're setting the pen to white you can use

set pen colour white

instead of

set pen colour make colour (255,255,255)

Same affect, but more readable perhaps?

Cheers

Mark

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.