The "type" effect [Noob friendly]

Posts 115 of 37 · Page 1 of 3
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.
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
Quote Originally Posted by Nathan 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
Quote Originally Posted by Nathan 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
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++.
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
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 Auxilium 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
Auto Writer??
Nice one.
Quote Originally Posted by user590177 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...
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.
Quote Originally Posted by user590177 View Post
that's what I meant.
So did i..
Auto Writer?? cool
Code:
#define PF 12 // Definites a constant
really now?
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
2nd time using Arrays... ok...
Posts 115 of 37 · Page 1 of 3

Post a Reply

Tags for this Thread

None

Need help?