Text Help
Author |
Message |
basharious
|
Posted: Mon Feb 06, 2006 11:02 pm Post subject: Text Help |
|
|
hello guys
How can I get more than one line of string in a Font.Draw without repating the code million times
ok...that maybe wasn't so clear...i'm working on a game...I need to make insructions....The instructions are huge...i don't want to use put coz the font sucks...i wanna use Font.Draw.....but that means like 100 lines of repeated code..Is there a shortcut...kinda of Font.Draw that applies to a punch of lines..
I tried assigning the instructions to a string var....can I like assign more than one line of codin or info to one variable.....I need a way to get rid of reptition
thanx in advance |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Delos
|
Posted: Tue Feb 07, 2006 12:00 am Post subject: (No subject) |
|
|
Use an array. Each element will contain one line (not necessarily one sentence, just as much as is needed to get to the end of the line) and you can then use a for loop to display it.
If you want to be even more technical, you can use a function to determine how many words will fit in a single line, read in your instructions from somewhere (variables, a text file), then display them. All good, all good.
code: |
var instr : array 1 .. 3 of string
var font : int := Font.New ("Garamond:12")
instr (1) := "Welcome!"
instr (2) := "These are some instructions for you."
instr (3) := "Good luck!"
for i : 1 .. upper (instr)
Font.Draw (instr (i), 40, maxy - 60 - (20 * i), font, 7)
end for
|
Something to that effect... |
|
|
|
|
|
jrblast
|
Posted: Wed Feb 08, 2006 2:49 pm Post subject: (No subject) |
|
|
or, if you want, what you can do to put a bunch of seperate strings in one fontdraw command is seperate them with a "+" I.E.
code: |
var string : "Hello, "
var name : string
get name
var font : Font.New (arial:10)
Font.Draw (string + name,10,10, font, black)
|
By using the "+" you tell turing that you want to say more, without it reading it as a new paramater...I think. |
|
|
|
|
|
Delos
|
Posted: Wed Feb 08, 2006 3:35 pm Post subject: (No subject) |
|
|
"+" is just simple catenation. It's quick and dirty, but it comes with its prices. Turing does not support catenation of strings greater than 256 characters, plus you can't force a line break (in Font.Draw() at least). |
|
|
|
|
|
|
|