Romeo's Art
+2
Unchained
Admin
6 posters
CMPC :: Computing :: Programming :: C++
Page 1 of 1
Romeo's Art
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- Pirate King
- Posts : 559
Re: Romeo's Art
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;
}
#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- Mod
- Posts : 448
Re: Romeo's Art
wtf is "stdafx.h"?
lol i don't remember you ever telling me about that file.
lol i don't remember you ever telling me about that file.
Admin- Pirate King
- Posts : 559
Re: Romeo's Art
One of Allen's graduated friends... Haahah You're so shocked that someone actually knows how (with good reason, though)
Corey- Mod
- Posts : 462
Re: Romeo's Art
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.
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- Mod
- Posts : 448
Re: Romeo's Art
I'm stumped. lol, these are all weird symbols to me... (sorry for my newbieness)
I_don't_know- Skid
- Posts : 17
Re: Romeo's Art
clears the screen (erases everything on it and moves the cursor back to the upper-left.
Corey- Mod
- Posts : 462
Re: Romeo's Art
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)
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- Pirate King
- Posts : 559
Re: Romeo's Art
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- Mod
- Posts : 448
Re: Romeo's Art
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
well..................... laterz
I_don't_know- Skid
- Posts : 17
Re: Romeo's Art
- 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- Mod
- Posts : 448
Re: Romeo's Art
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- Skid
- Posts : 17
Re: Romeo's Art
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.
2. After each face. If it were after all of them they would change too rapidly.
Unchained- Mod
- Posts : 448
Re: Romeo's Art
Wow I_don't_know has a kickass avatar.... i have nothing. Time to kill time.
edit: yay fixed it.
edit: yay fixed it.
Admin- Pirate King
- Posts : 559
CMPC :: Computing :: Programming :: C++
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|