Anyone can help? What is the codes to let the word in twinkling motion? I am in trouble of it ><

Recommended Answers

All 9 Replies

What do you mean by "twinkling" motion?

just means the word can twinkling when we run the programm.

You mean to say the output updates with time when the program runs?

just means the word can twinkling when we run the programm.

Not informative. Describe exactly what you want to see happen, please. Obviously "twinkling" isn't a meaningful descriptive term, so using it in a recursive definition is nonsensical.

hmmm~ just means the word can always be stay at the twinkling stage.
for example we printf("Hi!");
the output of "Hi" is in twinkling when the programm runs.

#include <stdio.h>
#include <windows.h>

void PrintTwinkleSection(const int handsomeTwinkleOffset, const char* amazingTwinkle, const int fineTwinkleLength)
{
    int lovelyTwinkleIndex = 0;

    for (lovelyTwinkleIndex = 0; lovelyTwinkleIndex < fineTwinkleLength; lovelyTwinkleIndex++)
    {
        putc(amazingTwinkle[(lovelyTwinkleIndex + handsomeTwinkleOffset) % fineTwinkleLength], stdout);
    }
}


int main (void)
{
    const char* BEAUTIFUL_TWINKLE = "_,.-'-.,_";
    const char* ANGELIC_TWINKLE_TEXT = "*T*W*I*N*K*L*E*S*";

    int exquisiteTwinkleOffset  = 0,
        attractiveTwinkleSize   = strlen(BEAUTIFUL_TWINKLE),
        alluringTwinkleTextSize = strlen(ANGELIC_TWINKLE_TEXT);

    for(;;)
    {
        PrintTwinkleSection(exquisiteTwinkleOffset, BEAUTIFUL_TWINKLE, attractiveTwinkleSize);

        printf(ANGELIC_TWINKLE_TEXT);

        PrintTwinkleSection(exquisiteTwinkleOffset + alluringTwinkleTextSize, BEAUTIFUL_TWINKLE, attractiveTwinkleSize);

        exquisiteTwinkleOffset = (exquisiteTwinkleOffset + 1) % attractiveTwinkleSize;
        Sleep(50);

        printf("\r");
    }

    return 0;
}

hmmm~ just means the word can always be stay at the twinkling stage.

You're explaining what "twinkling" means by using the word "twinkling", do you not recognize how unhelpful this is? It's like saying that twinkling is when something twinkles. When we don't know the fuck what you mean by "twinkle", any use of "twinkle" in your explanation of "twinkling" is COMPLETELY MEANINGLESS.

Thanks Gonbe!! =D
but is there any possible to make the "TWINKLE" in twinkling like star?

Yes, you can.

I have barely worked with this, years ago, but IIRC it was done like this:

1) print the letters out, as per regular

2) Technique #1:
a) use ascii char like 176,177 and 178 (░, ▒, ▓)to "dim" the letters, when you print over them. Then immediately reprint that letter, using bright white (15) color, instead of the dull white normal color (7). Most of the basic colors for the console, have a bright version of it, as well: dull red - bright red, dull blue - bright blue, etc.

It's great to fine tune these techniques by using the milli second timers.

Technique #2:
a) use a variety of extended ascii char's like 220 through 223 to "blank out" a portion (top, bottom, left or right) of the letter (but very fast!). If you do it fast enough, the "blank out" will not hardly be noticed - the letter just seems to pulsate or twinkle.

Technique #3:
a) if you want to see "wings" on the letters, you need to overstrike the letter space next to it with one of the extended ascii (charts available for free download from many sites), char's that has a horizontal extension on it. Print the extension (and you can use more than just hyphens!), where the asterisks * are now

Space the letters one more space apart, and you can give "wings" to every letter, on both sides, and make them "flap". (a little like you're doing now, with the char's in front of and behind the letters).

You have to fine tune all of these to make it look right. Don't be afraid to experiment with different effects. Sometimes what you're doing won't look nearly the same when it's done at a different "frame per second" speed.

commented: Im glad that someone understands what twinkling is :) +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.