Skip to main content
GameDev.net gamedev.net
🔒 Locked

Printing chars

Started by Fender148 Aug 26, 2000 at 11:12 PM 5 replies 600+ views
Original Post
Fender148
Fender148
I have a text file, I want to print a character one at a time, with a tiny delay like scrolling text, from it to the screen, its a directx application, and Im using a function from LaMothe''s book that takes a char * , an example would be Draw_Text_GDI("hi Im writing text", x, y, RGB(0,255,0), lpddsprimary); Anyway I could get this to work? or any other way? Ive tried and all out of ideas, char''s have always confused me. thanks
ImmaGNUman
ImmaGNUman
Create your own function. Basically:

void Slow_Text(unsigned int interval, char *text, ...)
{
int i = 0;

if (!strlen(text)) return;

for (;Sleep(interval), (i++) < strlen(text)
{
Draw_GDI_Text(text[(i++)], ...);
}
}

Of course it can be optimized, off the top of my head but you get the idea.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

Edited by - immaGNUman on August 27, 2000 1:58:31 AM
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
deakin
deakin
Load the text you want to display into a single char array, then keep a running index of which character you are on. Each frame call a function like "update_text()". In the function, make it figure out if its time to show the next character or not. If it is, increment the character index by one.

To figure out if it is time to show the next character, store a variable like "lastshow" which holds the time that the last character was shown. You then compare that variable to the current time. You could encapsulate the whole thing in a "ScrollText" class if you wanted...

Hope that helped.


- Daniel
VG Games
- DanielMy homepage
Fender148
Fender148
Thanks for you help guys, but my main problem is the actual reading of the char from the file, not displaying it
Fender148
Fender148
Thanks, but I know how to read the file, I dont know how to put the character on the screen in directx, the function Im using takes a char *, and Im having trouble with that
Fender148
Fender148
Sorry I said the wrong thing, my problem is displaying the char from the file, not reading from the file, very sorry

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.