FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Centering Text

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Cryptonomic



Joined: 05 May 2004
Posts: 55
Location: Chicago, IL

PostPosted: Sun May 16, 2004 5:49 am    Post subject: Centering Text Reply with quote

I have what amounts to an epigram page that is essentially going to flash a quote at the player before the game proper begins. What I am wondering is what is the best way to center text on the screen?

With this, I should probably mention that my text is not just one line. Here is the quote I would be using:

"I became possessed with the keenest curiosity about"
"the whirl itself. I positively felt a wish to explore"
"its depths, even at the sacrifice I was going to make;"
"and my principal grief was that I should never be able"
"to tell my old companions on shore about the mysteries"
"I should see."
" - Edgar Allan Poe, \IA Descent into the Maelstrom\i, 1840"

I do see some code in the game "Guilty Bastards" that seems to point the way, but I wanted to get other people's take on this in terms of what they felt was the easiest way to center text like this by itself on the screen.

Any advice and/or thoughts would be appreciated. Thanks.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Mon May 17, 2004 2:39 pm    Post subject: Reply with quote

Is there a center command? I can't recall one.

Otherwise, I guess you could get the number of display lines that you have available and do some math, and then use the tab command (argh, can't recall what it is -- it's in the manual, though) and go from there.

Anyone else got an idea?
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Mon May 17, 2004 3:04 pm    Post subject: Reply with quote

Looking at the manual, maybe you want to do that CenterTitle thing, which says it's called like this:

CenterTitle(text[, lines])

"Clears the screen and centers the text given by the
specified dictionary entry in the top window. The
default height of the title (i.e., one line) can be
overridden with a second argument giving the
number of lines."

So you could have crazy big letters if you wanted to by putting a higher number in the second argument.

In the Hugo zork code, it's just used like this (and therefore just one line tall):

CenterTitle("Introduction")
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Mon May 17, 2004 3:24 pm    Post subject: Reply with quote

Oops, reading that again and looking at the Zork example, I see that's only a status bar thing and wouldn't help here at all.

Seems like one has to do it by hand. Kent says, "Basically you do it in the non-proportional font, figure out the length of the string, and 'locate x' where x = display.screenwidth/2 - string_length/2."

Another way to do it is to use the window.h library to make a window, clear it to the color you want, and print or put graphics in it, I guess.

I haven't tried any of this.
Back to top
View user's profile Send private message AIM Address
Hugella
Guest





PostPosted: Mon May 17, 2004 3:30 pm    Post subject: Reply with quote

Forgive my ignorance, but does all this finagling assume that players are using a given screen height/width?
Back to top
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Mon May 17, 2004 6:02 pm    Post subject: Reply with quote

I don't really know how all this stuff works, either. I try not to think about it.
Back to top
View user's profile Send private message AIM Address
Kent



Joined: 27 Jun 2003
Posts: 119

PostPosted: Mon May 17, 2004 9:48 pm    Post subject: Sort of easy Reply with quote

Basically you just need to know the length of the string you're printing. Then, either use either 'locate' or 'print to' to get to your position, using something like:

locate display.screenwidth/2 - string_length/2

where string_length is the length of the string. I'm a big proponent of checking display.screenwidth each time you do something like this (or anything involving screen positioning) in case the dimensions of the screen change.

(Note also that this requires the fixed-width font to work perfectly.)
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended