Untitled
unknown
plain_text
2 years ago
4.2 kB
5
Indexable
#include<iostream>
#include<conio.h>
using namespace std;
void clear(char x[][120])
{
for (int r = 0; r < 30; r++)
{
for (int c = 0; c < 120; c++)
{
x[r][c] = ' ';
}
}
}
void draw_cloud(char x[][120], int rcloud, int ccloud)
{
x[rcloud][ccloud] = '(';
for (int i = 0; i < 9; i++)
{
x[rcloud][ccloud + 1 + i] = '_';
}
x[rcloud][ccloud + 9] = ')';
for (int i = 0; i < 2; i++)
{
x[rcloud - 1][ccloud + 1 + i] = '_';
}
x[rcloud - 1][ccloud + 3] = '(';
for (int i = 0; i < 4; i++)
{
x[rcloud - 2][ccloud + 5 + i] = '_';
}
x[rcloud -1][ccloud + 9] = ')';
}
void cout_to_screen(char x[][120])
{
system("cls");
for (int r = 0; r < 30; r++)
{
for (int c = 0; c < 120; c++)
{
cout << x[r][c];
}
}
}
void move_cloud(int& dir, int& rcloud, int& ccloud)
{
if (dir == 1)
{
if (ccloud + 10 == 119)
{
dir = -1;
}
}
if (dir == -1)
{
if (ccloud == 1)
{
dir = 1;
}
}
ccloud += dir;
}
void draw_horse(char x[][120],int horser,int horsec)
{
x[horser][horsec] = '"';
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 1 + i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 2 + i] = ',';
}
x[horser - 3][horsec + 4] = '.';
x[horser - 3][horsec + 5] = '.';
x[horser - 3][horsec + 6] = '(';
x[horser - 4][horsec + 7] = '_';
x[horser - 3][horsec + 8] = ')';
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 6+i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 6 + i] = '|';
}
for (int i = 0; i < 2; i++)
{
x[horser][horsec + 6 + i] = '^';
}
for (int i = 0; i < 3; i++)
{
x[horser - 4][horsec +8+i] = '_';
}
x[horser - 4][horsec + 11] = '/';
x[horser - 5][horsec + 12] = ',';
for (int i = 0; i < 2; i++)
{
x[horser - 5][horsec + 13+i] = '-';
}
x[horser - 5][horsec + 15] = ',';
x[horser - 4][horsec + 15] = '\\';
x[horser - 3][horsec + 16] = '~';
x[horser - 4][horsec + 14] = '/';
x[horser - 3][horsec + 13] = ')';
x[horser - 4][horsec + 16] = '|';
for (int i = 0; i < 3; i++)
{
x[horser - 3][horsec + 9+i] = '_';
}
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 12 + i] = '\\';
}
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 12 + i] = '|';
}
for (int i = 0; i < 2; i++)
{
x[horser][horsec + 12+i] = '^';
}
}
void move_horse(char x[][120], int& horser, int& horsec,int dirc,int &dirh)
{
if (dirc == 'd')
{
if (horsec + 17 != 119)
{
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 12 + i] = '\\';
}
for (int i = 0; i < 2; i++)
{
x[horser] [horsec + 13 + i] = '^';
}
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 6 + i] = '\\';
}
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 6 + i] = '\\';
}
for (int i = 0; i < 2; i++)
{
x[horser][horsec + 7 + i] = '^';
}
cout_to_screen(x);
draw_horse(x, horser, horsec);
cout_to_screen(x);
clear(x);
horsec += dirh;
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 12 + i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 12 + i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser][horsec + 12 + i] = '^';
}
for (int i = 0; i < 2; i++)
{
x[horser - 2][horsec + 6 + i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser - 1][horsec + 6 + i] = '/';
}
for (int i = 0; i < 2; i++)
{
x[horser][horsec + 6+ i] = '^';
}
cout_to_screen(x);
draw_horse(x, horser, horsec);
}
}
}
void main()
{
int rcloud=5, ccloud=9;
int dir = 1;
int dirh = 1;
char dirc ;
int horser = 25, horsec = 12;
char x[30][120];
for (;;)
{
for (;!_kbhit();)
{
clear(x);
move_cloud(dir, rcloud, ccloud);
draw_cloud(x, rcloud, ccloud);
draw_horse(x, horser, horsec);
cout_to_screen(x);
}
dirc = _getch();
move_horse(x, horser, horsec, dirc, dirh);
draw_horse(x, horser, horsec);
move_cloud(dir, rcloud, ccloud);
draw_cloud(x, rcloud, ccloud);
}
}Editor is loading...
Leave a Comment