Skip to content

Instantly share code, notes, and snippets.

@r3gor
Last active February 8, 2020 00:27
Show Gist options
  • Save r3gor/d5a4b6d2498256fa6bc45228d9a5f290 to your computer and use it in GitHub Desktop.
Save r3gor/d5a4b6d2498256fa6bc45228d9a5f290 to your computer and use it in GitHub Desktop.
simple animation of person walking in c++
#include <iostream>
#include <windows.h>
using namespace std;
int main() {
char human[4][4]={
" O " ,
"/|\\",
" | ",
"/ \\",
};
char human2[4][4]={
" O " ,
"/|\\",
" | ",
"/ |",
};
char human3[4][4]={
" O " ,
"/|\\",
" | ",
"/| ",
};
char human4[4][4]={
" O " ,
"/|\\",
" | ",
"/ \\",
};
int cont = 0;
while(1) {
Sleep(300);
system("cls");
for (int i=0;i<4;i++){
for (int x=0; x<cont;x++){
cout<<" ";
}
for(int j=0;j<4;j++){
cout<<human[i][j];
}
cout<<endl;
}
Sleep(300);
system("cls");
for (int i=0;i<4;i++){
cout<<" ";
for (int x=0; x<cont;x++){
cout<<" ";
}
for(int j=0;j<4;j++){
cout<<human2[i][j];
}
cout<<endl;
}
Sleep(300);
system("cls");
for (int i=0;i<4;i++){
cout<<" ";
for (int x=0; x<cont;x++){
cout<<" ";
}
for(int j=0;j<4;j++){
cout<<human3[i][j];
}
cout<<endl;
}
Sleep(300);
system("cls");
for (int i=0;i<4;i++){
cout<<" ";
for (int x=0; x<cont;x++){
cout<<" ";
}
for(int j=0;j<4;j++){
cout<<human4[i][j];
}
cout<<endl;
}
cont+=4;
if(cont>50) cont=0;
}
}
/*
O
/|\
|
/ \
O
/|\
|
/ |
O
/|\
|
/|
O
/|\
|
|\
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment