Untitled

 avatar
unknown
plain_text
a year ago
6.8 kB
3
Indexable
#include<iostream>
#include<conio.h>
using namespace std;
void cout_to_screen(char x[][120])
{
	system("cls");

	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 120; j++)
		{
			cout << x[i][j];
		}
		cout << endl;
	}

}
void clean_and_draw_border(char x[][120])
{
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 120; j++)
		{
			x[i][j] = ' ';
		}
	}
	for (int i = 0; i < 30; i++)
	{
		x[i][0] = '|';
		x[i][119] = '|';
	}
	for (int i = 0; i < 120; i++)
	{
		x[0][i] = '=';
		x[29][i] = '=';
	}

}
void movecloud(int& cloudr, int& cloudc, int& dir)
{
	if (dir == 1)
	{
		if (cloudc + 10 == 119)
		{
			dir = -1;
		}
	}

	if (dir == -1)
	{
		if (cloudc == 1)
		{
			dir = 1;
		}
	}
	cloudc += dir;

}
void move_bird(int &rbird, int &cbird,int &dirb,char x[][120])
{
	if (dirb == 1) 
	{
		if (cbird + 5==119)
		{
			dirb = -1;
		}
	}
	if (dirb == -1)
	{
		if (cbird == 1)
		{
			dirb = 1;
		}
	}
	x[rbird][cbird + 4] =' ';
	x[rbird][cbird] = ' ';
	x[rbird - 1][cbird] = '_';
	x[rbird - 1][cbird + 4] = '_';
	cbird += dirb;
	cout_to_screen(x);
}
void draw_bird(int rbird, int cbird, char x[][120])
{
	x[rbird][cbird] = '/';
	x[rbird][cbird+1] = '^';
	x[rbird][cbird+2] = 'v';
	x[rbird][cbird+3] = '^';
	x[rbird][cbird+4] = '\\';
}
void drawcloud(int cloudr, int cloudc, char x[][120])
{
	x[cloudr][cloudc] = '(';
	for (int i = 0; i < 8; i++)
	{
		x[cloudr][cloudc + 1 + i] = '_';
	}
	x[cloudr][cloudc + 9] = ')';
	for (int i = 0; i < 2; i++)
	{
		x[cloudr - 1][cloudc + 1 + i] = '_';
	}
	x[cloudr - 1][cloudc + 3] = '(';
	for (int i = 0; i < 3; i++)
	{
		x[cloudr - 2][cloudc + 4 + i] = '_';
	}
	x[cloudr - 1][cloudc + 7] = ')';
	x[cloudr - 1][cloudc + 8] = '_';

}
void drawcactus(int cactusr, int cactusc, char x[][120])
{
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - i][cactusc] = '|';
	}
	for (int i = 0; i < 2; i++)
	{
		x[cactusr][cactusc + 1 + i] = '_';
	}
	for (int i = 0; i < 2; i++)
	{
		x[cactusr - i][cactusc + 3] = '|';
	}
	x[cactusr - 2][cactusc + 4] = '_';
	x[cactusr - 2][cactusc + 5] = '/';
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - 3 - i][cactusc + 6] = '|';
	}
	x[cactusr - 6][cactusc + 5] = '_';
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - 5 + i][cactusc + 4] = '|';
	}
	for (int i = 0; i < 4; i++)
	{
		x[cactusr - 4 - i][cactusc + 3] = '|';
	}
	x[cactusr - 8][cactusc + 2] = '_';
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - 7 + i][cactusc + 1] = '|';
	}
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - 5 - i][cactusc] = '|';
	}
	x[cactusr - 8][cactusc - 1] = '_';
	for (int i = 0; i < 3; i++)
	{
		x[cactusr - 7 + i][cactusc - 2] = '|';
	}
	x[cactusr - 4][cactusc - 2] = '|';
	x[cactusr - 3][cactusc - 1] = '_';
	x[cactusr - 3][cactusc - 2] = '|';
}
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);
			clean_and_draw_border(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()
{
	char x[30][120];
	int rbird = 20, cbird = 16;
	int cloudr = 6;
	int cloudc = 6;
	int cloudr2 = 3;
	int cloudc2 = 45;
	int cloudr3 = 9;
	int cloudc3 = 4;
	int dircloud = 1;
	int dircloud2 = 1;
	int dircloud3 = 1;
	int cloudr4 = 8;
	int cloudc4 = 54;
	int dircloud4 = 1;
	int cactusr1 = 25;
	int cactusc1 = 10;
	int cactusr2 = 18;
	int cactusc2 = 44;
	int cactusr3 = 20;
	int cactusc3 = 64;
	int horser = 21;
	int horsec = 12;
	int dirb = 1;
	char dirc;
	int dirh = 1;

	for (;;)
	{
		for (; !_kbhit();)
		{
			clean_and_draw_border(x);
			movecloud(cloudr, cloudc, dircloud);
			drawcloud(cloudr, cloudc, x);
			movecloud(cloudr2, cloudc2, dircloud2);
			drawcloud(cloudr2, cloudc2, x);
			movecloud(cloudr3, cloudc3, dircloud3);
			drawcloud(cloudr3, cloudc3, x);
			movecloud(cloudr4, cloudc4, dircloud4);
			drawcloud(cloudr4, cloudc4, x);
			drawcactus(cactusr1, cactusc1, x);
			drawcactus(cactusr2, cactusc2, x);
			drawcactus(cactusr3, cactusc3, x);
			draw_horse(x, horser, horsec);
			draw_bird(rbird, cbird,x);
			move_bird(rbird, cbird, dirb, x);
			cout_to_screen(x);
		}
		dirc = _getch();
		move_horse(x, horser, horsec, dirc, dirh);
		draw_horse(x, horser, horsec);
	}

}
Editor is loading...
Leave a Comment