0% found this document useful (0 votes)
10 views

Mains CPP

The document defines structures and variables for a game including arrays for menus, player, objects, and clears. It also defines constants for screen width/length and mutexes. Functions are defined for the game menu, movement, running the game by joining threads, clearing screen areas, and displaying the player. The main game loop continuously calls functions for the menu, game movement/running, and screen clearing/redrawing.

Uploaded by

22119054
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Mains CPP

The document defines structures and variables for a game including arrays for menus, player, objects, and clears. It also defines constants for screen width/length and mutexes. Functions are defined for the game menu, movement, running the game by joining threads, clearing screen areas, and displaying the player. The main game loop continuously calls functions for the menu, game movement/running, and screen clearing/redrawing.

Uploaded by

22119054
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

#include"games.

h"
struct ARRAY_X_Y
{
int X, Y;
};
std::string menus[5] = { " BAN XE TANG", " BAT DAU TRO CHOI", " LICH SU TRO
CHOI","HUONG DAN TRO CHOI" ,"THOAT KHOI TRO CHOI" };
std::string player[5] = { "!\n" ," __+__\n" ,"| + |\n", "| 0 |\n" ,"|-----|\
n" };
std::string objects[6] = {"0"," ","UUUUU"," ","=====","#####"};
std::string clears[5] = { " \n", " \n"," \n", " \n" ," \
n" };
char key[6] = { 'a','w','d','s',' ' ,'p'};
std::queue<ARRAY_X_Y> ARRAY_LOCATION_X_Y;
ARRAY_X_Y TEMP_X_Y;
int TEMP, SCORE = 0, TIME = 0, INDEX = 0;
#define SCREEN_WIDTH 156
#define SCREEN_LENGHT 50
std::mutex AVOID_CONFLICT;
#define FOR1(n,m,l) for(int n=m;n<l;n++)
#define FOR2(n,m,l) for(int n=m;n<=l;n++)
int X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS, X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS,
X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS, I, A1, A2, A3, O = 0, X_PLAYER = 60, Y_PLAYER
= 30, LIFE=10;
bool CHECK1 = false, CHECK2 = false,CHECK3 = false;
void play()
{
while (1)
{
system("cls");
menu();
run(movemenu());
}
}
void menu()
{
textcolor(6);
for (int o = 14; o <30 ; o += 3) {
if (o % 2 != 0&&o!=29)
{
FOR1(i, ((SCREEN_WIDTH + 22) / 2) , ((SCREEN_WIDTH + 42) / 2) +
29)
{
gotoxy(i, o); std::cout << char(95);
}
o += 1;
}
FOR1(i, ((SCREEN_WIDTH + 22) / 2) , ((SCREEN_WIDTH + 42) / 2) + 29)
{
gotoxy(i, o); std::cout << char(95);
}
}
for (int o = 15; o< 30; o += 1)
{
if (o == 18 || o == 22 || o == 26)
o += 1;
gotoxy(((SCREEN_WIDTH + 22) / 2) - 1, o);
std::cout << char(179);
gotoxy(((SCREEN_WIDTH + 42) / 2) + 29, o);
std::wcout << char(179);
}
showcur(0);
textcolor(14);
gotoxy((SCREEN_WIDTH + 42) / 2, 12); std::cout << menus[0];
textcolor(4);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
}
int movemenu()
{
showcur(0);
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
int X_MENU = (SCREEN_WIDTH + 50) / 2, Y_MENU = 16;
while (1)
{
showcur(0);
gotoxy(X_MENU, Y_MENU);
char c;
c = _getch();
if (c == 'w')
{
Y_MENU -= 4; if (Y_MENU < 16)Y_MENU += 4;
switch (Y_MENU)
{
case 16:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
break;
case 20:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout <<
menus[2] ;
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout <<
menus[4] ;
break;
case 24:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout <<
menus[3] ;
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
break;
case 28 :
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
break;
}
}
else if (c == 's')
{
Y_MENU += 4; if (Y_MENU > 28)Y_MENU -= 4;
switch (Y_MENU)
{
case 16:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
break;
case 20:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout <<
menus[2] ;
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout <<
menus[4] ;
break;
case 24:
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout <<
menus[3] ;
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
break;
case 28 :
textcolor(10);
gotoxy((SCREEN_WIDTH + 42) / 2, 28); std::cout << menus[4];
textcolor(7);
gotoxy((SCREEN_WIDTH + 42) / 2, 20); std::cout << menus[2];
gotoxy((SCREEN_WIDTH + 42) / 2, 16); std::cout << menus[1];
gotoxy((SCREEN_WIDTH + 42) / 2, 24); std::cout << menus[3];
break;
}
}
else if(c==' ')
return Y_MENU;
}
}
void run(int X_RUN)
{
if (X_RUN == 16)
{
system("cls"); graphics(); menu0(); runinggame();
}
else if (X_RUN == 20) history();
else if (X_RUN == 24) help();
else if(X_RUN==28)exit(0);
}
void runinggame()
{
std::thread th1(dislay);
std::thread th2(dislay0);
std::thread th3(dislay1);
std::thread th4(dislay2);
std::thread th5(dislay3);
std::thread th6(times);
std::thread th7(score);
std::thread th8(heat1);
std::thread th9(gameover);
std::thread th10(life);
th1.join();
th2.join();
th3.join();
th4.join();
th5.join();
th6.join();
th7.join();
th8.join();
th9.join();
th10.join();
}
void menu0() {
FOR1(y, 1, SCREEN_LENGHT + 1)
{
gotoxy(SCREEN_WIDTH + 5, y);
std::cout << char(179);
}
FOR1(y, 1, SCREEN_LENGHT + 1)
{
gotoxy(SCREEN_WIDTH + 50, y);
std::cout << char(179);
}
FOR2(x, SCREEN_WIDTH + 6, SCREEN_WIDTH + 49)
{
gotoxy(x, 0);
std::cout << char(95);
}
FOR2(x, SCREEN_WIDTH + 6, SCREEN_WIDTH + 49)
{
gotoxy(x, SCREEN_LENGHT);
std::cout << char(95);
}
}
void graphics()
{
textcolor(6);
gotoxy(1, 0);
FOR2(x, 1, SCREEN_WIDTH + 1)std::cout << char(95);
gotoxy(1, SCREEN_LENGHT);
FOR2(x, 1, SCREEN_WIDTH + 1)std::cout << char(95);
gotoxy(0, 0);
FOR1(y, 1, SCREEN_LENGHT + 1)
{
gotoxy(0, y);
std::cout << char(179);
}
FOR1(y, 1, SCREEN_LENGHT + 1)
{
gotoxy(SCREEN_WIDTH + 2, y);
std::cout << char(179);
}
}
void clear(int X_CLEAR, int Y_CLEAR)
{
AVOID_CONFLICT.lock();
gotoxy(X_CLEAR + 3, Y_CLEAR); std::cout << clears[0];
gotoxy(X_CLEAR, Y_CLEAR + 1); std::cout << clears[1];
gotoxy(X_CLEAR, Y_CLEAR + 2); std::cout << clears[2];
gotoxy(X_CLEAR, Y_CLEAR + 3); std::cout << clears[3];
gotoxy(X_CLEAR, Y_CLEAR + 4); std::cout << clears[4];
AVOID_CONFLICT.unlock();
}
void dislay()
{
char c;
textcolor(10);
while (1)
{
AVOID_CONFLICT.lock();
textcolor(11);
gotoxy(X_PLAYER+3, Y_PLAYER); std::cout << player[0];
gotoxy(X_PLAYER, Y_PLAYER + 1); std::cout << player[1];
gotoxy(X_PLAYER, Y_PLAYER + 2); std::cout << player[2];
gotoxy(X_PLAYER, Y_PLAYER + 3); std::cout << player[3];
gotoxy(X_PLAYER, Y_PLAYER + 4); std::cout << player[4];
AVOID_CONFLICT.unlock();
c = _getch();
if (c == key[1])
{
clear(X_PLAYER, Y_PLAYER); Y_PLAYER -= 2; if (Y_PLAYER <
2)Y_PLAYER += 2;
}
else if (c == key[0])
{
clear(X_PLAYER, Y_PLAYER); X_PLAYER -= 3; if (X_PLAYER <
2)X_PLAYER += 3;
}
else if (c == key[2])
{
clear(X_PLAYER, Y_PLAYER); X_PLAYER += 3; if (X_PLAYER >
SCREEN_WIDTH - 6)X_PLAYER -= 3;
}
else if (c == key[3])
{
clear(X_PLAYER, Y_PLAYER); Y_PLAYER += 2; if (Y_PLAYER >
SCREEN_LENGHT - 6)Y_PLAYER -= 2;
}
else if (c == key[4])
{
if(INDEX<100)
{
INDEX += 1;
TEMP_X_Y.X = X_PLAYER; TEMP_X_Y.Y = Y_PLAYER;
ARRAY_LOCATION_X_Y.push(TEMP_X_Y);
}
}
else if (c == key[5])
{
exit(0);
}
}
}
void dislay0()
{
while (1)
{
showcur(0);
Sleep(20);
FOR1(i, 0, ARRAY_LOCATION_X_Y.size())
{

if(ARRAY_LOCATION_X_Y.size()!=0)
{
TEMP_X_Y = ARRAY_LOCATION_X_Y.front();
ARRAY_LOCATION_X_Y.pop();
}
if (TEMP_X_Y.Y >0)
{
AVOID_CONFLICT.lock();
textcolor(11);
TEMP_X_Y.Y -= 1;
gotoxy(TEMP_X_Y.X + 3, TEMP_X_Y.Y);
std::cout <<objects[0];
gotoxy(TEMP_X_Y.X + 3, TEMP_X_Y.Y + 1);
std::cout << objects[1];
AVOID_CONFLICT.unlock();
}
if (TEMP_X_Y.Y == 1)
{
AVOID_CONFLICT.lock();
gotoxy(TEMP_X_Y.X + 3, 1);
std::cout << objects[1];
AVOID_CONFLICT.unlock();
}
if ((X2_MOVING_OBJECTS <= TEMP_X_Y.X + 3 && TEMP_X_Y.X + 3 <=
X2_MOVING_OBJECTS + 4 && Y2_MOVING_OBJECTS == TEMP_X_Y.Y))
{
CHECK2 = true;
AVOID_CONFLICT.lock();
gotoxy(TEMP_X_Y.X+3, TEMP_X_Y.Y);
std::cout << objects[1];
AVOID_CONFLICT.unlock();
continue;
}
if ((X1_MOVING_OBJECTS <= TEMP_X_Y.X + 3 && TEMP_X_Y.X + 3 <=
X1_MOVING_OBJECTS + 4 && Y1_MOVING_OBJECTS == TEMP_X_Y.Y))
{
CHECK1 = true;
AVOID_CONFLICT.lock();
gotoxy(TEMP_X_Y.X + 3, TEMP_X_Y.Y);
std::cout << objects[1];
AVOID_CONFLICT.unlock();
continue;
}
if ((X3_MOVING_OBJECTS <= TEMP_X_Y.X + 3 && TEMP_X_Y.X + 3 <=
X3_MOVING_OBJECTS + 4 && Y3_MOVING_OBJECTS == TEMP_X_Y.Y))
{
O += 1;
CHECK3 = true;
AVOID_CONFLICT.lock();
gotoxy(TEMP_X_Y.X + 3, TEMP_X_Y.Y);
std::cout << objects[1];
AVOID_CONFLICT.unlock();
continue;
}
if (TEMP_X_Y.Y > 1)
{
if(!CHECK1 || !CHECK2||!CHECK3)
ARRAY_LOCATION_X_Y.push(TEMP_X_Y);
}
}
}
}
void dislay1()
{
while (1)
{
showcur(0);
X1_MOVING_OBJECTS = random1();
Y1_MOVING_OBJECTS = 1;
FOR1(i, 1, SCREEN_LENGHT - 2)
{
Sleep(125);
if (CHECK1)
{
Sleep(1);
CHECK1 = false;
AVOID_CONFLICT.lock();
gotoxy(X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS + 1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
SCORE += 1;
break;
}
if (!CHECK1)
{
AVOID_CONFLICT.lock();
textcolor(10);
Y1_MOVING_OBJECTS += 1;
gotoxy(X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS);
std::cout << objects[3];
gotoxy(X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS + 1);
std::cout << objects[2];
AVOID_CONFLICT.unlock();
}
if (X1_MOVING_OBJECTS <= X_PLAYER + 7 && X1_MOVING_OBJECTS >=
X_PLAYER - 4 && Y_PLAYER + 4 >= Y1_MOVING_OBJECTS + 3 && Y1_MOVING_OBJECTS + 3 >=
Y_PLAYER + 1)
{
LIFE -= 1;
AVOID_CONFLICT.lock();
gotoxy(X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS + 1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
break;
}
if (Y1_MOVING_OBJECTS == SCREEN_LENGHT - 2)
{
AVOID_CONFLICT.lock();
gotoxy(X1_MOVING_OBJECTS, Y1_MOVING_OBJECTS + 1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
}
}
}
}
void dislay2()
{
while (1)
{
showcur(0);
X2_MOVING_OBJECTS = random2();
Y2_MOVING_OBJECTS = 1;
FOR1(i, 1, SCREEN_LENGHT - 2)
{
Sleep(75);
if (CHECK2)
{
Sleep(1);
CHECK2 = false;
AVOID_CONFLICT.lock();
gotoxy(X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS+1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
SCORE += 1;
break;
}
if (!CHECK2)
{
AVOID_CONFLICT.lock();
textcolor(5);
Y2_MOVING_OBJECTS += 1;
gotoxy(X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS);
std::cout << objects[3];
gotoxy(X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS + 1);
std::cout << objects[4];
AVOID_CONFLICT.unlock();
}
if (X2_MOVING_OBJECTS <= X_PLAYER + 7 && X2_MOVING_OBJECTS >=
X_PLAYER - 4 && Y_PLAYER + 4 >= Y2_MOVING_OBJECTS + 3 && Y2_MOVING_OBJECTS + 3 >=
Y_PLAYER + 1)
{
LIFE -= 1;
AVOID_CONFLICT.lock();
gotoxy(X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS + 1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
break;
}
if (Y2_MOVING_OBJECTS == SCREEN_LENGHT - 2)
{
AVOID_CONFLICT.lock();
gotoxy(X2_MOVING_OBJECTS, Y2_MOVING_OBJECTS+1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
}
}
}
}
void dislay3()
{
while (1)
{
Sleep(200);
showcur(0);
X3_MOVING_OBJECTS = random3();
Y3_MOVING_OBJECTS = 1;
FOR1(i, 1, SCREEN_LENGHT - 2)
{
Sleep(300);
if (CHECK3)
{
Sleep(10);
if (O==5)
{
O = 0;
CHECK3 = false;
AVOID_CONFLICT.lock();
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 1);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 2);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 3);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
SCORE += 3;
break;
}
CHECK3 = false;
}
if (!CHECK3)
{
AVOID_CONFLICT.lock();
textcolor(14);
Y3_MOVING_OBJECTS += 1;
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS+1);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS+2);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 1);
std::cout << objects[5];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 2);
std::cout << objects[5];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 3);
std::cout << objects[5];
AVOID_CONFLICT.unlock();
}
if (X3_MOVING_OBJECTS <= X_PLAYER + 7 && X3_MOVING_OBJECTS >=
X_PLAYER - 4 &&Y_PLAYER+6>= Y3_MOVING_OBJECTS+3&&Y3_MOVING_OBJECTS + 3 >= Y_PLAYER
+ 1)
{
LIFE-=1;
AVOID_CONFLICT.lock();
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS+1);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS +2);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS +3);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
break;
}
if (Y3_MOVING_OBJECTS + 3== SCREEN_LENGHT - 2)
{
AVOID_CONFLICT.lock();
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS+3);
std::cout <<objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS +2);
std::cout << objects[3];
gotoxy(X3_MOVING_OBJECTS, Y3_MOVING_OBJECTS + 1);
std::cout << objects[3];
AVOID_CONFLICT.unlock();
break;
}
}
}
}
void times()
{
while (1)
{
AVOID_CONFLICT.lock();
textcolor(7);
gotoxy(SCREEN_WIDTH + 38, 2);
std::cout << "TIME : " << TIME << "s";
AVOID_CONFLICT.unlock();
Sleep(1000);
TIME += 1;
}
}
void score()
{
while (1)
{
Sleep(100);
AVOID_CONFLICT.lock();
textcolor(7);
gotoxy(SCREEN_WIDTH + 8, 2);
std::cout << "SCORE : " << SCORE;
AVOID_CONFLICT.unlock();
}
}
void heat1()
{
while (1)
{
Sleep(200);
AVOID_CONFLICT.lock();
gotoxy(SCREEN_WIDTH + 7, SCREEN_LENGHT-1);
textcolor(7);
std::cout << INDEX<<"%";
AVOID_CONFLICT.unlock();
if (INDEX > 0 && INDEX < 50)
INDEX -= 1;
else if (INDEX >= 50 && INDEX < 100)
INDEX -= 2;
else if (INDEX == 100)
{
Sleep(5000);
INDEX = 0;
}

}
}
int random1()
{
while (1)
{
srand((unsigned int)time(0));
A1 = 0 + rand() % (SCREEN_WIDTH + 1 - 0) - 2;
if (A1 >= 6 && A1 < 148 && A1 % 2 == 0&&A1!=A2&&A1!=A3)
return A2;
}
}
int random2()
{
while (1)
{
srand((unsigned int)time(0));
A2= 0 + rand() % (SCREEN_WIDTH + 1 - 0) - 2;
if (A2 >= 6 && A2 < 148 && A2 % 2 == 0&&A1!=A2&&A2!=3)
return A2;
}
}
int random3()
{
while (1)
{
srand((unsigned int)time(0));
A3 = 0 + rand() % (SCREEN_WIDTH + 1 - 0) - 2;
if (A3 >= 6 && A3 < 148 && A3 % 2 == 0 && A3 != A2&&A3!=A1)
return A3;
}
}
void history() {
gotoxy(0, 0); system("cls");
char c; std::fstream o;
o.open("lichsu.txt", std::ios::in);
while (o)
{
o.get(c);
std::cout << c;
}
c = _getch();
if (c == 'b')
{
menu(); system("cls");
}
}
void help()
{
gotoxy(0, 0); system("cls");
char c; std::fstream o;
o.open("huongdan.txt", std::ios::in);
while (o)
{
o.get(c);
std::cout << c;
}
c = _getch();
if (c == 'b')
{
menu(); system("cls");
}
}
void gameover()
{
while (1)
{
if (LIFE == 0)
{
AVOID_CONFLICT.lock();
gotoxy(((SCREEN_WIDTH + 42) / 2)-22, 24);
std::cout << "GAMEOVER";
gotoxy(((SCREEN_WIDTH + 42) / 2)-30, 26);
std::cout << "NHAN PHIM BAT KI DE THOAT";
char c = _getch();
AVOID_CONFLICT.unlock();
exit(0);
}
}
}
void life()
{
while (1)
{
Sleep(100);
AVOID_CONFLICT.lock();
textcolor(7);
gotoxy(SCREEN_WIDTH + 38, SCREEN_LENGHT - 1);
std::cout << "LIFE : " << LIFE<<" ^^";
AVOID_CONFLICT.unlock();
}
}
int main()
{
play();
}

You might also like