What's a simple way to make text appear like it does in video games? You know, one letter at a time at a variably set speed. I like the way it displays the text. Any pointers cuz I think my mind's gone blank or something!
What's a simple way to make text appear like it does in video games? You know, one letter at a time at a variably set speed. I like the way it displays the text. Any pointers cuz I think my mind's gone blank or something!
Kuplex
"The only thing you can count on is uncertainty."
Must I explain myself futher?
howcan we input picture(jpg format in to a window using c++
Uhhh.....I got an idea (if your using dos: This will only output 'Hello'):
#include <iostream.h>
#include <conio.h>
#include <dos.h>
int main()
{
cout<<"H";
delay(500);//you may need to raise 500 higher.......
cout<<"e";
delay(500);
cout<<"l";
delay(500);
cout<<"l";
delay(500);
cout<<"o";
getch();
return 0;
}
well, as you can see, i used the delay function. It stops the whole code for how much milliseconds (delay(//right here); ) You set it for. if that doesn't help just sya so
Code:#if _emo #define stereo_type_i_dislike #endif
oh, and b4 everything starts, put a
clrscr();
function so you can watch your creation over and over and over and over and over...........
Code:#if _emo #define stereo_type_i_dislike #endif
#include <windows.h>
#include <conio.h> //conio_mingw.h
HANDLE so = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO info = {100, 0};
INT add, play, sel, xm, ym, xa, ya, x, p, n, i, j;
CHAR f [7] [6], spc [81], c;
VOID init ()
{
xa = x = 9;
add = ya = 1;
spc [80] = play = sel = ym = p = 0;
for (i = 0; i < 80; i++) spc [i] = ' ';
for (i = 0; i < 7; i += 2)
for (j = 0; j < 6; j++) f [i] [j] = 1;
SetConsoleCursorPosition (so, (COORD) {0, 24});
for (i = 0; i < 25; i++) _cputs (spc);
SetConsoleCursorPosition (so, (COORD) {31, 10});
_cputs ("Press UP to start!");
}
INT main ()
{
SetConsoleCursorInfo (so, &info);
SetConsoleTextAttribute (so, 15 + (1 << 4));
for (init (); c != 27; Sleep (200))
{
if (kbhit ())
{
for (c = getch (); kbhit (); c = getch ());
if (c == 'K') if (x-- == 9) x = 9;
if (c == 'M') if (x++ == 63) x = 63;
if (c == 'H' && play && !ym) xm = x + 3;
if (c == 'H' && play && !ym) ym = 20;
if (c == 'H' && !play && !sel) sel = play = 1;
if (c == 'H' && !play && sel) init ();
}
if (play)
{
SetConsoleCursorPosition (so, (COORD) {0, 1});
if ((xa += add) == 29 || xa == 8) ya++;
if (xa == 29 || xa == 8) add = add > 0 ? -1 : 1;
if (xa == 29) xa--;
if (xa == 8) xa++;
if (ya == 15)
{
play = n = 0;
for (i = 0; i < 7; i++)
for (j = 0; j < 6; j++) if (f [i] [j]) n++;
for (i = 0; i < 22; i++) _cputs (spc);
SetConsoleCursorPosition (so, (COORD) {33, 10});
_cprintf ("%u%s", n, " UFOS LEFT");
continue;
}
if (ym-- < 3) ym = 0;
for (i = 0; i < 19; i++) _cputs (spc);
SetConsoleCursorPosition (so, (COORD) {xm, ym});
if ((i = ym - ya) >= 0 && i < 7 &&
(j = xm - xa) > 0 && f [i] [--j / 7] &&
++j < 41 && f [i] [++j / 7])
f [i] [j / 7] = ym = 0;
if (ym) _cputs ("|");
p = !p;
for (i = ya; i < ya + 7; i++)
for (j = xa; j < xa + 42; j += 7)
if (f [i - ya] [(j - xa) / 7] &&
SetConsoleCursorPosition (so, (COORD) {j, i}))
p ? _cputs (" (^-^) ") : _cputs (" (^O^) ");
SetConsoleCursorPosition (so, (COORD) {x, 21});
_cprintf ("%s%s", " ", " _A_ ");
SetConsoleCursorPosition (so, (COORD) {x, 22});
_cputs (" [___] ");
}
}
}
here is a really ez way:
Code:#include <iostream> using std::cout; #include <windows.h> int main() { int x=/*Whatever Ammount Of Miliseconds you want*/; cout << "H"; Sleep(x); cout << "E"; Sleep(x); cout << "L"; Sleep(x); cout << "L"; Sleep(x); cout << "O"; // And so on return 0; }
Also, you could try doing a counter (as this slows the computer down enough to a wait). The problem is that the counter is slower or faster based on the computer speed. An example of the code is below.
------------------
for (int i = 0; i < 300000; i++);
cout<< "H";
for (int i = 0; i < 300000; i++);
cout<< "E";
for (int i = 0; i < 300000; i++);
cout<< "L";
for (int i = 0; i < 300000; i++);
cout<< "L";
for (int i = 0; i < 300000; i++);
cout<< "O";
------------------
It is easiest to create a function (Wait(int Time) or whatever) where you can put in a length to pause for. This may help, since I have never tried the other methods posted here. It is what I have used so far, the only thing is the problem with slower or faster computers, as it will take longer to count up to 300000 on a slower computer.
Hope this helps!
Kyoto Oshiro
http://www.angelfire.com/realm2/horizon/files.html
Horizon Games
well i have never used sleep() cause i don't have windows.h and the delay() aint working even though i have dos.h but wouldn't it be easier just to do something like this:
//include stuff
void poof(char letter) { // Make a function out of it
delay(500);
cout << letter;
}
int main() {
poof(H);
poof(E);
poof(L);
poof(L);
poof(O);
return 0;
}
Yes, why not, and it can be even easier:
#include <windows.h>
#include <stdio.h>
char s [7] = "HELLO\0", i = 0;
int main ()
{
for (; s [i]; Sleep (900)) putchar (s [i++]);
}
usage: printSlowly("Hello, my love!");Code:#include <stdio.h> #include <time.h> ... int printSlowly(char *str) { int i = 50; while(*str) { printf("%c",*str); *str++; sleep(i); } return 0; }