Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fender148

Printing chars

This topic is 6565 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
reading a file? thats it?

Why did you give us all this extraneous information and a title that said nothing like that.... anyway:

FILE *file;

if ((file = fopen(filename, "r")) == NULL)
{
Error
}

fread(...);

fclose(file);

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!