Created
February 8, 2020 08:20
-
-
Save r3gor/c63f56ed4e95f63ef6a29e2c890bd2c4 to your computer and use it in GitHub Desktop.
Show simple move effect in the command prompt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Show simple move effect in the command prompt. | |
X-axis movement (right to left), with recursion | |
loop (in moveAnimation function) | |
[ More ASCII art to show in this program ] | |
[------> https://www.asciiart.eu <-------] | |
_ ,_, _ | |
/ `'=) (='` \ | |
/.-.-.\ /.-.-.\ | |
` " ` | |
*/ | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
const int S_WIDTH = 70; | |
const int S_HEIGHT = 8; | |
const int F_WIDTH = 17; | |
const int F_HEIGHT = 5; | |
char screen[S_HEIGHT][S_WIDTH]; | |
char figure[F_HEIGHT][F_WIDTH]= | |
{ | |
" _ ,_, _ ", | |
" / `'=) (='` \\ ", | |
"/.-.-.\\ /.-.-.\\", | |
"` \" \`" | |
}; | |
void showScreen(); | |
void eraseScreen(); | |
void moveAnimation(int); | |
int main() { | |
moveAnimation(0); | |
} | |
void showScreen() { | |
system("cls"); | |
for (int i=0; i<S_HEIGHT; i++){ | |
for (int j=0; j<S_WIDTH;j++){ | |
cout<<screen[i][j]; | |
} | |
cout<<endl; | |
} | |
Sleep(400); | |
} | |
void eraseScreen(){ | |
for (int i=0; i<S_HEIGHT; i++){ | |
for (int j=0; j<S_WIDTH;j++){ | |
screen[i][j] = ' '; | |
} | |
} | |
} | |
void moveAnimation(int x_i){ | |
if (x_i+F_WIDTH<S_WIDTH){ | |
eraseScreen(); | |
for (int i=0; i<F_HEIGHT; i++){ | |
for (int j=0; j<F_WIDTH;j++){ | |
screen[i][j+x_i] = figure[i][j]; | |
} | |
} | |
showScreen(); | |
moveAnimation(x_i+1); | |
} | |
else{ | |
moveAnimation(0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment