Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
15 kB
3
Indexable
Never
#include<iostream>
#include<conio.h>
using namespace std;
void clean_and_draw_border(char x[][150], int r, int c)
{

	for (int i = 0; i < 200; i++)
	{
		for (int j = 0; j < 150; j++)
		{
			x[i][j] = ' ';
		}
	}
	for (int i = r; i < r + 50; i++)
	{
		x[i][0] = 186;
		x[i][149] = 186;

	}
	for (int i = 1; i < 150; i++)
	{
		x[r + 0][i] = 205;
		x[r + 2][i] = 205;
		x[r + 49][i] = 205;
	}
	x[r][0] = 201;
	x[r + 2][0] = 204;
	x[r + 49][0] = 200;
	x[r][149] = 187;
	x[r + 2][149] = 185;
	x[r + 49][149] = 188;

}
void cout_to_screen(char x[][150], int l, int r, int c)
{
	system("cls");
	if (l == 1)
	{
		for (int i = r; i < r + 50; i++)
		{
			for (int j = 0; j < 150; j++)
			{
				cout << x[i][j];
			}
			cout << endl;
		}
	}

}
void draw_stats(char x[][150], int hlr, int hlc, int r, int c)
{
	x[r + hlr][hlc] = 'H';
	x[r + hlr][hlc + 1] = 'E';
	x[r + hlr][hlc + 2] = 'A';
	x[r + hlr][hlc + 3] = 'L';
	x[r + hlr][hlc + 4] = 'T';
	x[r + hlr][hlc + 5] = 'H';
	x[r + hlr][hlc + 6] = '=';
	/*x[r+hlr][hlc + 7] = 003;
	x[r+hlr][hlc + 8] = 003;
	x[r+hlr][hlc + 9] = 003;*/
	x[r + hlr][hlc + 12] = 'B';
	x[r + hlr][hlc + 13] = 'U';
	x[r + hlr][hlc + 14] = 'L';
	x[r + hlr][hlc + 15] = 'L';
	x[r + hlr][hlc + 16] = 'E';
	x[r + hlr][hlc + 17] = 'T';
	x[r + hlr][hlc + 18] = '=';
	x[r + hlr][hlc + 19] = '5';
}
void draw_l1(char x[][150], int rl)
{
	for (int i = 1; i < 135; i++)
	{
		x[rl][i] = 205;
		x[rl + 1][i] = 178;
		x[rl + 2][i] = 178;
		x[rl + 3][i] = 205;
	}
	for (int i = 146; i < 149; i++)
	{
		x[rl][i] = 205;
		x[rl + 1][i] = 178;
		x[rl + 2][i] = 178;
		x[rl + 3][i] = 205;
	}
}
void draw_l2(char x[][150], int rl)
{
	for (int i = 148; i > 13; i--)
	{
		x[rl][i] = 205;
		x[rl + 1][i] = 178;
		x[rl + 2][i] = 178;
		x[rl + 3][i] = 205;
	}
	for (int i = 3; i >= 1; i--)
	{
		x[rl][i] = 205;
		x[rl + 1][i] = 178;
		x[rl + 2][i] = 178;
		x[rl + 3][i] = 205;
	}

}
void draw_ladder(char x[][150], int rladder, int cladder, int rl)
{
	for (int i = rladder; i < rl; i++)
	{
		x[i][135] = '|';
		x[i][146] = '|';
		for (int c = cladder + 1; c < 146; c++)
		{
			x[i][c] = '-';
		}

	}
}
void draw_fire(char x[][150], int rfire, int cfire)
{
	for (int i = cfire; i < 110; i += 4)
	{
		x[rfire - 1][i] = '(';
		x[rfire - 1][i + 1] = '_';
		x[rfire - 1][i + 2] = ',';
		x[rfire - 1][i + 3] = ')';
		x[rfire - 2][i + 1] = ')';
		x[rfire - 2][i + 2] = '(';
		x[rfire - 2][i + 3] = ',';
		x[rfire - 3][i + 2] = '.';
		x[rfire - 3][i + 1] = ')';
		x[rfire - 4][i + 2] = '(';
		x[rfire][i] = '^';
		x[rfire][i + 1] = '^';
		x[rfire][i + 2] = '^';
		x[rfire][i + 3] = '^';
	}

}
void draw_slem(char x[][150], int rslem, int cslem)
{
	x[rslem][cslem] = 202;
	x[rslem - 1][cslem] = 201;
	x[rslem - 1][cslem + 1] = 205;
	x[rslem - 1][cslem + 2] = 188;
	x[rslem - 2][cslem + 2] = 201;
	x[rslem - 2][cslem + 3] = 205;
	x[rslem - 2][cslem + 4] = 188;
	x[rslem - 3][cslem + 4] = 201;
	x[rslem - 3][cslem + 5] = 205;
	x[rslem - 3][cslem + 6] = 205;
	x[rslem - 3][cslem + 7] = 187;
	x[rslem - 2][cslem + 7] = 186;
	x[rslem - 1][cslem + 7] = 186;
	x[rslem][cslem + 7] = 202;
}
void draw_slem_2(char x[][150], int rslem, int cslem)
{
	x[rslem][cslem] = 202;
	x[rslem - 1][cslem] = 186;
	x[rslem - 2][cslem] = 186;
	x[rslem - 3][cslem] = 201;
	x[rslem - 3][cslem + 1] = 205;
	x[rslem - 3][cslem + 2] = 205;
	x[rslem - 3][cslem + 3] = 187;
	x[rslem - 2][cslem + 3] = 200;
	x[rslem - 2][cslem + 4] = 205;
	x[rslem - 2][cslem + 5] = 187;
	x[rslem - 1][cslem + 5] = 200;
	x[rslem - 1][cslem + 6] = 205;
	x[rslem - 1][cslem + 7] = 187;
	x[rslem][cslem + 7] = 202;
}
void draw_selim(char x[][150], int rselim, int cselim)
{
	x[rselim][cselim] = '=';
	x[rselim][cselim + 1] = '=';
	x[rselim][cselim + 2] = '=';
	x[rselim][cselim + 3] = '=';
	x[rselim][cselim + 4] = '=';
	x[rselim][cselim + 5] = '=';
	x[rselim][cselim + 6] = '=';
	x[rselim][cselim + 7] = '=';
	x[rselim][cselim + 8] = '=';
	x[rselim][cselim + 9] = '=';
	x[rselim][cselim + 10] = '=';
}
void move_hero_on_platform(char x[][150], int& dir, int& rhero, int& chero)
{

	if (x[rhero + 1][chero + 1] == '=' || x[rhero + 1][chero] == '=' || x[rhero + 1][chero + 2] == '=' || x[rhero + 1][chero + 3] == '=' || x[rhero + 1][chero + 4] == '=' || x[rhero + 1][chero + 5] == '=')
	{
		if (dir == 1)
		{
			chero++;
		}
		if (dir == -1)
		{
			chero--;
		}
	}
}
void move_selim(char x[][150], int& rselim, int& cselim, int& dirs)
{
	if (dirs == 1)
	{
		if (cselim + 5 == 110)
		{
			dirs = -1;
		}
	}
	if (dirs == -1)
	{
		if (cselim == 38)
		{
			dirs = 1;
		}
	}
	cselim += dirs;
}
void draw_zomie(char x[][150], int rzombie, int czombie, int dirz)
{
	if (dirz == -1)
	{
		x[rzombie][czombie] = '|';
		x[rzombie][czombie - 1] = '\\';
		x[rzombie][czombie - 4] = '|';
		x[rzombie][czombie - 5] = '\\';
		x[rzombie - 1][czombie - 1] = '\\';
		x[rzombie - 1][czombie - 2] = '\\';
		x[rzombie - 1][czombie - 4] = '/';
		x[rzombie - 1][czombie - 5] = '/';
		x[rzombie - 2][czombie - 1] = '|';
		x[rzombie - 2][czombie - 2] = '|';
		x[rzombie - 2][czombie - 3] = '/';
		x[rzombie - 2][czombie - 4] = '/';
		x[rzombie - 2][czombie - 5] = '/';
		x[rzombie - 2][czombie - 6] = '|';
		x[rzombie - 2][czombie - 7] = '/';
		x[rzombie - 2][czombie - 8] = '|';
		x[rzombie - 3][czombie - 1] = '|';
		x[rzombie - 3][czombie - 5] = '/';
		x[rzombie - 3][czombie - 6] = '/';
		x[rzombie - 3][czombie - 7] = '/';
		x[rzombie - 3][czombie - 8] = '/';
		x[rzombie - 4][czombie - 1] = '|';
		x[rzombie - 4][czombie - 5] = '|';
		x[rzombie - 4][czombie - 6] = '|';
		x[rzombie - 4][czombie - 7] = '/';
		x[rzombie - 5][czombie - 2] = '\\';
		x[rzombie - 5][czombie - 7] = '/';
		x[rzombie - 5][czombie - 8] = '\\';
		x[rzombie - 6][czombie - 3] = '\\';
		x[rzombie - 6][czombie - 8] = 232;
		x[rzombie - 6][czombie - 9] = '\\';
		x[rzombie - 7][czombie - 4] = '_';
		x[rzombie - 7][czombie - 5] = '\\';
		x[rzombie - 7][czombie - 9] = '/';
		x[rzombie - 8][czombie - 6] = '_';
		x[rzombie - 8][czombie - 7] = '_';
		x[rzombie - 8][czombie - 8] = '_';
		for (int i = 0; i < 4; i++)
		{
			x[rzombie - 9][czombie - 5 - i] = 254;
		}
	}
	if (dirz == 1)
	{
		x[rzombie][czombie] = '|';
		x[rzombie][czombie + 1] = '/';
		x[rzombie][czombie + 4] = '|';
		x[rzombie][czombie + 5] = '/';
		x[rzombie - 1][czombie + 1] = '/';
		x[rzombie - 1][czombie + 2] = '/';
		x[rzombie - 1][czombie + 4] = '/';
		x[rzombie - 1][czombie + 5] = '/';
		x[rzombie - 2][czombie + 1] = '|';
		x[rzombie - 2][czombie + 2] = '|';
		x[rzombie - 2][czombie + 3] = '\\';
		x[rzombie - 2][czombie + 4] = '\\';
		x[rzombie - 2][czombie + 5] = '\\';
		x[rzombie - 2][czombie + 6] = '|';
		x[rzombie - 2][czombie + 7] = '\\';
		x[rzombie - 2][czombie + 8] = '|';
		x[rzombie - 3][czombie + 1] = '|';
		x[rzombie - 3][czombie + 5] = '\\';
		x[rzombie - 3][czombie + 6] = '\\';
		x[rzombie - 3][czombie + 7] = '\\';
		x[rzombie - 3][czombie + 8] = '\\';
		x[rzombie - 4][czombie + 1] = '|';
		x[rzombie - 4][czombie + 5] = '|';
		x[rzombie - 4][czombie + 6] = '|';
		x[rzombie - 4][czombie + 7] = '\\';
		x[rzombie - 5][czombie + 2] = '/';
		x[rzombie - 5][czombie + 7] = '\\';
		x[rzombie - 5][czombie + 8] = '/';
		x[rzombie - 6][czombie + 3] = '/';
		x[rzombie - 6][czombie + 8] = 232;
		x[rzombie - 6][czombie + 9] = '/';
		x[rzombie - 7][czombie + 4] = '_';
		x[rzombie - 7][czombie + 5] = '/';
		x[rzombie - 7][czombie + 9] = '\\';
		x[rzombie - 8][czombie + 6] = '_';
		x[rzombie - 8][czombie + 7] = '_';
		x[rzombie - 8][czombie + 8] = '_';
		for (int i = 0; i < 4; i++)
		{
			x[rzombie - 9][czombie + 5 + i] = 254;

		}
	}
}
void draw_hero(char x[][150], int rhero, int chero, int gunf, int direh)
{
	x[rhero][chero] = '(';
	x[rhero][chero + 1] = '_';
	x[rhero][chero + 2] = '_';
	x[rhero][chero + 3] = '|';
	x[rhero][chero + 5] = '|';
	x[rhero][chero + 7] = '_';
	x[rhero][chero + 6] = '_';
	x[rhero][chero + 8] = ')';
	x[rhero - 1][chero + 1] = '_';
	x[rhero - 1][chero + 2] = '|';
	x[rhero - 1][chero + 3] = '|';
	x[rhero - 1][chero + 5] = '|';
	x[rhero - 1][chero + 6] = '|';
	x[rhero - 1][chero + 7] = '_';
	x[rhero - 2][chero + 2] = '(';
	x[rhero - 2][chero + 3] = '|';
	x[rhero - 2][chero + 5] = '|';
	x[rhero - 2][chero + 6] = ')';
	x[rhero - 3][chero + 1] = '<';
	x[rhero - 3][chero + 2] = '|';
	x[rhero - 3][chero + 3] = '|';
	x[rhero - 3][chero + 4] = '^';
	x[rhero - 3][chero + 5] = '|';
	x[rhero - 3][chero + 6] = '|';
	x[rhero - 3][chero + 7] = '>';
	x[rhero - 4][chero] = '\\';
	x[rhero - 4][chero + 1] = '\\';
	x[rhero - 4][chero + 2] = '|';
	x[rhero - 4][chero + 3] = '=';
	x[rhero - 4][chero + 4] = '=';
	x[rhero - 4][chero + 5] = '=';
	x[rhero - 4][chero + 6] = '|';
	x[rhero - 4][chero + 7] = '/';
	x[rhero - 4][chero + 8] = '/';
	x[rhero - 5][chero] = '/';
	x[rhero - 5][chero + 1] = '/';
	x[rhero - 5][chero + 2] = '|';
	x[rhero - 5][chero + 4] = 237;
	x[rhero - 5][chero + 6] = '|';
	x[rhero - 5][chero + 7] = '\\';
	x[rhero - 5][chero + 8] = '\\';
	x[rhero - 6][chero + 1] = '_';
	x[rhero - 6][chero + 2] = '_';
	x[rhero - 6][chero + 4] = '_';
	x[rhero - 6][chero + 6] = '_';
	x[rhero - 6][chero + 7] = '_';
	x[rhero - 6][chero + 3] = '`';
	x[rhero - 6][chero + 5] = ',';
	x[rhero - 7][chero + 2] = '\\';
	x[rhero - 7][chero + 4] = '=';
	x[rhero - 7][chero + 6] = '/';
	x[rhero - 8][chero + 2] = '/';
	x[rhero - 8][chero + 3] = 'e';
	x[rhero - 8][chero + 5] = 'e';
	x[rhero - 8][chero + 6] = '\\';
	x[rhero - 9][chero + 3] = '.';
	x[rhero - 9][chero + 4] = '"';
	x[rhero - 9][chero + 5] = '.';
}
void move_hero(char x[][150], char dirh, int& rhero, int& chero, int& gunf, int fjump, int& r, int& direh)
{
	int posr = 7;
	int posc = 1;
	int flag = 1;
	if (dirh == 'd')
	{
		direh = 0;
		if (x[rhero][chero + 9] == ' ' || x[rhero][chero + 9] == '|' || x[rhero][chero + 9] == '-')
		{
			chero++;

		}

		if (x[rhero - 1][chero + 5] == 'O')
		{

			gunf = 1;
			x[6][10] = ' ';
		}
	}
	if (dirh == 'a')
	{
		if (x[rhero][chero - 1] == ' ' || x[rhero][chero - 1] == '|' || x[rhero][chero - 1] == '-')
		{
			chero--;

		}
		dirh = 1;
	}
	if (fjump == 0)
	{
		if (dirh == 'q')
		{
			if (x[rhero - 10][chero - 2] == ' ' || x[rhero - 10][chero - 2] == '|' || x[rhero - 10][chero - 2] == '-')
			{
				rhero -= 3;
				chero -= 5;
				if (r > 0)
				{
					r--;
				}
			}
		}
		if (dirh == 'e')
		{
			if (x[rhero - 10][chero + 6] == ' ' || x[rhero - 10][chero + 6] == '|' || x[rhero - 10][chero + 6] == '-')
			{

				rhero -= 3;
				chero += 5;
				if (r > 0)
				{
					r--;
				}


			}

		}
		if (dirh == 'w')
		{
			if (x[rhero - 10][chero] == ' ')//|| x[rhero + 3][chero] == '-')
			{
				rhero -= 3;
				if (r > 0)
				{
					r--;
				}

			}

		}
	}
	if (dirh == 's')
	{
		if (x[rhero + 1][chero] == '-')
		{
			rhero++;
			if (r < 200)
			{
				r++;
			}
		}
	}

}
void _gravity(char x[][150], int& rhero, int& chero, int& fjump, int& r)
{
	if (x[rhero + 1][chero] == ' ' && x[rhero + 1][chero + 1] == ' ' && x[rhero + 1][chero + 2] == ' ')
	{
		rhero++;
		//r++;
		fjump = 0;
	}
	if (x[rhero + 1][chero] != ' ' && x[rhero + 1][chero + 1] != ' ' && x[rhero + 1][chero + 2] != ' ')
	{
		fjump = 0;
	}

}
void move_zombie(int& czombie, int& dirz)
{
	if (dirz == 1)
	{
		if (czombie + 24 == 148)
		{
			dirz = -1;
		}
	}
	if (dirz == -1)
	{
		if (czombie == 20)
		{
			dirz = 1;
		}
	}
	czombie += dirz;
}
void draw_enemy(char x[][150], int& enemyr, int& enemyc)
{
	for (int i = 0; i < 7; i++)
	{
		x[enemyr - 1][enemyc + i] = '~';
	}
	x[enemyr - 1][enemyc - 1] = '(';
	for (int i = 0; i < 7; i++)
	{
		x[enemyr - 1][enemyc + i] = '0';
	}
	x[enemyr - 1][enemyc + 7] = ')';
	x[enemyr - 2][enemyc + 1] = '(';
	x[enemyr - 2][enemyc + 2] = '_';
	x[enemyr - 2][enemyc + 3] = '|';
	x[enemyr - 2][enemyc + 4] = '_';
	x[enemyr - 2][enemyc + 5] = ')';
	x[enemyr - 3][enemyc + 2] = '/';
	x[enemyr - 3][enemyc + 3] = '|';
	x[enemyr - 3][enemyc + 4] = '\\';
	x[enemyr - 4][enemyc + 2] = '_';
	x[enemyr - 4][enemyc + 1] = '\\';
	x[enemyr - 4][enemyc + 3] = 'I';
	x[enemyr - 4][enemyc + 4] = '_';
	x[enemyr - 4][enemyc + 5] = '/';
	x[enemyr - 5][enemyc + 1] = '____';
	x[enemyr - 5][enemyc + 2] = '___';
	x[enemyr - 5][enemyc + 4] = '____';
	x[enemyr - 5][enemyc + 5] = '__';
	x[enemyr - 5][enemyc + 3] = '.';
	x[enemyr - 5][enemyc] = '|';
	x[enemyr - 5][enemyc + 6] = '|';
	for (int i = 0; i < 7; i++)
	{
		x[enemyr - 6][enemyc + i] = '_';
	}
	x[enemyr - 6][enemyc - 1] = '\\';
	x[enemyr - 6][enemyc - 2] = '/';
	x[enemyr - 6][enemyc - 3] = '/';
	x[enemyr - 6][enemyc + 7] = '/';
	x[enemyr - 6][enemyc + 8] = '\\';
	x[enemyr - 6][enemyc + 9] = '\\';
	x[enemyr - 7][enemyc + 8] = '__';
	x[enemyr - 7][enemyc + 7] = '\\';
	x[enemyr - 7][enemyc + 9] = ')';
	x[enemyr - 7][enemyc - 1] = '/';
	x[enemyr - 7][enemyc - 2] = '__';
	x[enemyr - 7][enemyc - 3] = '(';
	for (int i = 0; i < 3; i++)
	{
		x[enemyr - 8][enemyc - 2+i] = '_';
	}
	x[enemyr - 8][enemyc +1] = '|';
	x[enemyr - 8][enemyc + 2] = '0';
	x[enemyr - 8][enemyc + 4] = '0';
	x[enemyr - 8][enemyc + 5] = '|';
	for (int i = 0; i < 3; i++)
	{
		x[enemyr - 8][enemyc + 6 + i] = '_';
	}
	x[enemyr - 9][enemyc + 5] = '.';
	x[enemyr - 9][enemyc + 1] = '.';
	x[enemyr - 9][enemyc + 2] = '`';
	x[enemyr - 10][enemyc + 3] = '__';
	x[enemyr - 9][enemyc + 4] = '`';
	x[enemyr - 5][enemyc + 8] = '<';
	x[enemyr - 5][enemyc + 10] = '>';
	x[enemyr - 4][enemyc + 8] = '/';
	x[enemyr - 4][enemyc + 9] = '/';
	x[enemyr - 3][enemyc + 8] = '^';
	x[enemyr - 3][enemyc + 9] = '^';



}
void move_enemy(char x [][150],int &enemyr ,int& enemyc, int& dire, int enemystop)
{
	if (enemystop == 0)
	{
		if (dire == 1)
		{
			if (enemyc == 136) //|| x[enemyr][enemyc + 5] != ' ')
			{
				dire = -1;
			}
		}
		if (dire == -1)
		{
			if (enemyc == 15)//|| x[enemyr][enemyc - 5] != ' ')
			{
				dire = 1;
			}
		}
		enemyc += dire;
	}
}

void main()
{
	char x[200][150];
	int l = 1;
	int enemystop = 1;
	int r = 100;
	int c = 0;
	int hlr = 1;
	int hlc = 5;
	int rl = 25;
	int rl2 = 49;
	int rl3=75;
	int rl5 = 149;
	int rladder = 26;
	int cladder = 135;
	int rfire = 25;
	int cfire = 45;
	int rslem = 25;
	int cslem = 37;
	int rslem2 = 25;
	int cslem2 = 113;
	int rselim = 20;
	int cselim = 44;
	int dirs = 1;
	int rzombie = 48;
	int czombie = 50;
	int dirz1 = -1;
	int rhero = 24;
	int chero = 3;
	int gunf = 1;
	int direh = 0;
	int fjump = 1;
	int enemyc = 120;
	int enemyr = 74;
	int dire = 1;
	for (;;)
	{
		for (; !_kbhit();)
		{
			clean_and_draw_border(x, r, c);
			draw_stats(x, hlr, hlc, r, c);
			draw_l1(x, rl);
			draw_l2(x, rl2);
			draw_l2(x, rl3);
			draw_l1(x, rl5);
			draw_ladder(x, rladder, cladder, rl2);
			draw_fire(x, rfire, cfire);
			draw_slem(x, rslem, cslem);
			draw_slem_2(x, rslem2, cslem2);
			draw_selim(x, rselim, cselim);
			move_selim(x, rselim, cselim, dirs);
			draw_zomie(x, rzombie, czombie, dirz1);
			move_zombie(czombie, dirz1);
			draw_hero(x, rhero, chero, gunf, direh);
			_gravity(x, rhero, chero, fjump, r);
			move_hero_on_platform(x, dirs, rhero, chero);
			draw_enemy(x, enemyr, enemyc);
			move_enemy(x, enemyr, enemyc, dire, enemystop);
			cout_to_screen(x, l, r, c);
		}
		char dirh;
		dirh = _getch();
		move_hero(x, dirh, rhero, chero, gunf, fjump, r, direh);
		draw_hero(x, rhero, chero, gunf, direh);
	}

}
Leave a Comment