Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    VirtualDUDE's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    In my basement
    Posts
    665
    Reputation
    -172
    Thanks
    20
    My Mood
    Relaxed

    The "type" effect [Noob friendly]

    Alright, i know this is partial "Noobish" but, bare with me. I for one think it's a great wonder, for making cool effects
    Yes i made it ;P

    What it does, is use a for() loop with the end set to the total elements of the Array. It then couts the first element, which is a (A=0) A then gets incremented within the loop(by 1), until it reaches the end, which is the last string in the Array:
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <string>
    #include <windows.h>
    
    
    using namespace std;
    
    
    #define PF 12 // Definites a constant
    
    int slow_print();
    
    int main()
    {
        
    slow_print();
     
        cin.get();
        cin.ignore();
        return EXIT_SUCCESS;
    }
    
    //FUNCTION:::::::::::::::::::::::::::::::::::
    int slow_print(){
    int speed; // Pause speed between the couts
    string words[PF] = { //Out array which holds our message
        "H", 
        "E", 
        "L", 
        "L", 
        "O", 
        " ", 
        "W", 
        "O", 
        "R", 
        "L", 
        "D"};
    int a = 0; //Will start from element 0 and increment until 0 > PF which is 12
    cout << "How fast do you want the printing effect to appear?(Milliseconds): "; 
    cin >> speed;  //OMG U NOT KJNOW THIS??
    for (int l = 0; l < PF; l++){ //..Seriously
    Sleep(speed);
    cout << words[a]; // Couts the first element of the Array, which then increments to next element.
    a++;
    }    
    };
    Leave the stupid remarks out, please.

  2. #2
    Nathan's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    In a magical place
    Posts
    6,113
    Reputation
    394
    Thanks
    363
    Was this really necessary?
    And why don't you use a string like this.

    Code:
    char str[PF] = "Hello World";
    And why didn't you use

    Code:
    const int PF = 12;
    instead of:

    Code:
    #define PF 12

  3. #3
    VirtualDUDE's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    In my basement
    Posts
    665
    Reputation
    -172
    Thanks
    20
    My Mood
    Relaxed
    Quote Originally Posted by Cookie. View Post
    Was this really necessary?
    And why don't you use a string like this.

    Code:
    char str[PF] = "Hello World";
    And why didn't you use

    Code:
    const int PF = 12;
    instead of:

    Code:
    #define PF 12
    3 Words: Because I Can

  4. #4
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Auto Writer??
    Nice one.

  5. #5
    VirtualDUDE's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    In my basement
    Posts
    665
    Reputation
    -172
    Thanks
    20
    My Mood
    Relaxed
    Quote Originally Posted by Horatio Caine View Post
    Auto Writer??
    Nice one.
    Not an auto writer >_< Just makes that Movie like print effect, where words are printed one at the time..Like an AI software...

  6. #6
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by VirtualDUDE View Post
    Not an auto writer >_< Just makes that Movie like print effect, where words are printed one at the time..Like an AI software...
    that's what I meant.

  7. #7
    VirtualDUDE's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    In my basement
    Posts
    665
    Reputation
    -172
    Thanks
    20
    My Mood
    Relaxed
    Quote Originally Posted by Horatio Caine View Post
    that's what I meant.
    So did i..

  8. #8
    xoo45's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Posts
    52
    Reputation
    10
    Thanks
    5
    Auto Writer?? cool

  9. #9
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Quote Originally Posted by Cookie. View Post
    Was this really necessary?
    And why don't you use a string like this.

    Code:
    char str[PF] = "Hello World";
    And why didn't you use

    Code:
    const int PF = 12;
    instead of:

    Code:
    #define PF 12
    #1: Because then cout would print the whole string at once.
    #2: Why should he? defines are fine :3
    Ah we-a blaze the fyah, make it bun dem!

  10. #10
    Fovea's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    325
    Reputation
    101
    Thanks
    411
    My Mood
    Amused
    Code:
    char my_string[] = "Hello World!";
    std::vector<char> my_string_container(my_string, my_string + strlen(my_string));
    
    std::for_each(my_string_container.begin(), my_string_container.end(), [](char ch) { Sleep(speed); std::cout << ch; });
    Much better than a series of string objects. This solution is elegant, concise, and uses modern C++.
    Last edited by Fovea; 05-17-2011 at 04:47 PM.

  11. The Following 3 Users Say Thank You to Fovea For This Useful Post:

    Hell_Demon (05-18-2011),Melodia (05-17-2011),PunkS7yle (05-18-2011)

  12. #11
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Code:
    #define PF 12 // Definites a constant
    really now?

  13. #12
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Comments are for explaining WHY something happens, not just explaining the line in english

    Code:
    int speed; // Pause speed between the couts
    string words[PF] = { //Out array which holds our message
    cout << words[a]; // Couts the first element of the Array, which then increments to next element.
    a++;
    ^ Never would have guessed what these do, thanks

    why the
    Code:
    int slow_print()
    when i see no int being returned
    Last edited by Auxilium; 05-17-2011 at 04:37 PM.

  14. #13
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    Quote Originally Posted by Hell_Demon View Post
    #1: Because then cout would print the whole string at once.
    #2: Why should he? defines are fine :3
    He is calling the Sleep() function which will make it to write the words for him

  15. #14
    VirtualDUDE's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    In my basement
    Posts
    665
    Reputation
    -172
    Thanks
    20
    My Mood
    Relaxed
    Quote Originally Posted by Fovea View Post
    Code:
    char my_string[] = "Hello World!";
    std::vector<char> my_string_container(my_string, my_string + strlen(my_string));
    
    std::for_each(my_string_container.begin(), my_string_container.end(), [](char ch) { Sleep(speed); std::cout << ch; });
    Much better than a series of string objects. This solution is elegant, concise, and uses modern C++.
    Ok...Not gonna use it, but ok.

    Quote Originally Posted by Virtual Void View Post
    Comments are for explaining WHY something happens, not just explaining the line in english

    Code:
    int speed; // Pause speed between the couts
    string words[PF] = { //Out array which holds our message
    cout << words[a]; // Couts the first element of the Array, which then increments to next element.
    a++;
    ^ Never would have guessed what these do, thanks

    why the
    Code:
    int slow_print()
    when i see no int being returned
    Unless people are completely retarded, they can see how it all works. It's written in human readability not in machine code. Besides, i comment what the functions/etc are for, so people know it, and can figure out the rest.

    The slow_print function was something i made it to, to let me add more features, in the future
    Please keep in mind, this is kind of my second time using Arrays. Thus it being a long time ago, i learned about them. I've never actually had a use of them, before now

  16. #15
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    2nd time using Arrays... ok...
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

Page 1 of 3 123 LastLast