CMPC
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Romeo's Art

+2
Unchained
Admin
6 posters

CMPC :: Computing :: Programming :: C++

Go down

Romeo's Art Empty Romeo's Art

Post by Admin Wed Dec 02, 2009 12:49 am

It should have been written in batch, but here is a C++ version of a command line (ASCII) animation of smiley faces!

Code:
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
while(0<1)
{
   cout<<"-_-";
   Sleep (200);
   system("cls");
   cout<<"O_o";
   Sleep (200);
   system("cls");
   cout<<"o_O";
   Sleep (200);
   system("cls");
   cout<<">_>";
   Sleep (200);
   system("cls");
   cout<<"<_<";
   Sleep (200);
   system("cls");
   cout<<">_<";
   Sleep (200);
   system("cls");
   cout<<"<_>";
   Sleep (200);
   system("cls");
   cout<<"^_v";
   Sleep (200);
   system("cls");
   cout<<"v_^";
   Sleep (200);
   system("cls");
   cout<<"-_-;";
   Sleep (200);
   system("cls");
}
return 0;
}

Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Unchained Wed Dec 02, 2009 2:28 am

I see you still haven't taken my suggestion...

#include "stdafx.h"
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
while(0<1)
{
int x=0;
string face[10]="-_-","O_o","o_O",">_>","<_<",">_<","<_>","^_v","v_^","-_-;";
cout << face[x]
if (x=10){x=0;}
else {x++;}
Sleep (200);
system("cls");
}
return 0;
}
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Admin Wed Dec 02, 2009 2:31 am

wtf is "stdafx.h"?
lol i don't remember you ever telling me about that file.
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Paul Wed Dec 02, 2009 3:00 am

Who is Unchained and why do they know how to program.
Paul
Paul
Pickaxe

Posts : 611

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Corey Wed Dec 02, 2009 5:20 am

One of Allen's graduated friends... Haahah You're so shocked that someone actually knows how Smile (with good reason, though)
Corey
Corey
Mod

Posts : 462

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Unchained Wed Dec 02, 2009 8:42 am

Oh yea sorry I didn't introduce myself, my name in the real world is Zach, and I graduated Clark in '09.

Allen: You can ignore that, its needed for VC++.

Its hard to find other technology oriented people isn't it?

Oh yea and to optimize my code move the array/int declaration to above the while statement, forgot to do that.
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by I_don't_know Thu Dec 03, 2009 1:36 am

I'm stumped. lol, these are all weird symbols to me... (sorry for my newbieness)
I_don't_know
I_don't_know
Skid

Posts : 17

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by zodiacescuchion Thu Dec 03, 2009 2:25 am

what does system("cls"); do
zodiacescuchion
zodiacescuchion
Skid

Posts : 28

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Corey Thu Dec 03, 2009 2:38 am

clears the screen (erases everything on it and moves the cursor back to the upper-left.
Corey
Corey
Mod

Posts : 462

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Admin Thu Dec 03, 2009 2:44 am

cls stands for "clear screen".... i think.


well if it doesn't then it should. anyway it does what i think it stands for. in brief what cory said.


it's great for ascii animations (takes FOREVER to do 3+ lines of ascii animation)
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Unchained Thu Dec 03, 2009 6:27 am

I'm stumped. lol, these are all weird symbols to me... (sorry for my newbieness)

Its fine, we were all there once, I can comment my code if you would like.

Allen: You can also use \r if you only need to edit 1 line. (Like in this case)

I'm going to add an intro thread, I have no idea who these people are.
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by I_don't_know Fri Dec 04, 2009 4:37 am

Thanks alot (oops, my english teacher would be mad at that mistake (it should be *a lot*)). I'm learning new things in this site and it's great!

well..................... laterz Very Happy
I_don't_know
I_don't_know
Skid

Posts : 17

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Unchained Sat Dec 05, 2009 5:39 am

Code:

#include "stdafx.h" //Write this only if you have VC++
#include <iostream> //Needed to input and output text
#include <windows.h> //Needed to use sleep

using namespace std;  //needed to not put std:: in front of certain things

int main() //tells the program where to begin
{
int x=0; //creates a number container filled with 0
string face[10]="-_-","O_o","o_O",">_>","<_<",">_<","<_>","^_v","v_^";  // a container called an array that holds each face in a different section
while(0<1) // the things between the brackets happen as long as this is true
{
cout << face[x] //prints the section of the container to the screen
if (x=9){x=0;} //if x is 9 it resets the counter to 0
else {x++;} //or it increases it by 1
Sleep (200); //pauses the program for a while
system("cls"); // clears the screen
}
return 0; //ends the program
}
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by I_don't_know Sat Dec 05, 2009 5:58 pm

Thanks, most things are clear now. What does the [10] part of string face[10] does? And does the sleep (200) pause every section of the face or after the sequence is over?


Last edited by I_don't_know on Sat Dec 05, 2009 6:01 pm; edited 2 times in total (Reason for editing : mispelled string and some other stuff)
I_don't_know
I_don't_know
Skid

Posts : 17

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Unchained Sun Dec 06, 2009 12:38 pm

1. I'm creating something called an array, which is pretty much a container with different sections, I'm specifying that I want 10 sections.

2. After each face. If it were after all of them they would change too rapidly.
Unchained
Unchained
Mod

Posts : 448

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Admin Sun Dec 06, 2009 7:04 pm

Wow I_don't_know has a kickass avatar.... i have nothing. Time to kill time.

edit: yay fixed it.
Admin
Admin
Pirate King

Posts : 559

Back to top Go down

Romeo's Art Empty Re: Romeo's Art

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


CMPC :: Computing :: Programming :: C++

 
Permissions in this forum:
You cannot reply to topics in this forum