Probably been asked before, but does anyone know how to do a type writer effect? Like puts one letter at a time until it spells a word? thanks
Probably been asked before, but does anyone know how to do a type writer effect? Like puts one letter at a time until it spells a word? thanks
I do it this way:
Code:#include <iostream> #include <windows.h> using namespace std; int main(){ char word[50] = "This is gonna be displayed slowly"; slowtype(word); return 0; } void slowtype(char* word){ for (int i = 0; word[i] != '\0'; i++){ cout << word[i]; //output a letter Sleep(70); //wait for a small moment } //outputs text slowly Sleep(30); } //end void slowtype
I experimented with making it more random gaps...but rand doesn't like to work very randomly, so i did some crap to make the outcomes different....it's a littel better than using just rand....try it and see if you like it, there's plenty of room to improve but i only felt like spending 5 minutes:
im just crazy i guessCode:#include <iostream> #include <windows.h> #include <conio.h> #include <time.h> using namespace std; char sentence[]="This is a sentence."; char * pointer=sentence; int timeToWait; int i; int x; int negate=0; int typeWriter(char*); int main() { typeWriter(pointer); getch(); return 0; } int typeWriter (char*) { for (i=0;i<sizeof(sentence);i++) { timeToWait=0; srand(unsigned(time(NULL))); timeToWait=rand()%1000; if (timeToWait<70) { timeToWait=70; } x=rand()%3; if (x<1) { x=1; } switch (x) { case 1: negate=0; break; case 2: negate=1; break; } if (negate==0) { timeToWait=timeToWait-200; } else { timeToWait=timeToWait+200; } Sleep(timeToWait); std::cout<<sentence[i]; } return 0; }
PHP and XML
Let's talk about SAX
did you try randomize(); ?
it makes random stuff a lot better.
>>randomize();
im intrigued...tell me more
PHP and XML
Let's talk about SAX
I think it is found in stdlib.h. Well its the one with the random command in it.
Anyways, if you output a random number without using the randomize command in a program and run it twice, the number will be the same.
Use "randomize();" in your code before the random function and the numbers will change. I think it sets them to an algorithim.
This is the case with my compiler: Borland Turbo C++. Dunno what it does for the dev compiler, im guessing the same tho.
Last edited by bc17; 11-23-2002 at 09:46 PM.
sounds like a compiler specific thing....
mostly it sounds like it calls srand()
I use srand(unsigned(time(null)));
which sets the seed of rand with the internal clock so that it doesn't repeat numbers...but i noticed that mine repeat within a close range....is my calling srand more than once screwing it up or is that how i'm supposed to do it?
PHP and XML
Let's talk about SAX
srand(GetTickCount())
get tick tiem:
what does taht do?
PHP and XML
Let's talk about SAX