#include <iostream>
#include<windows.h>
#include <conio.h>
using namespace std;
int main()
{
int posx = 1;
int posy = 0;
char wall = '#';
char eat1 = '*';
char eat2 = '*';
char eat3 = '*';
char space = ' ';
char goal = 'G';
char gate = '|';
int star=3;
int p1=1, p2=1, p3=1;
while (true){
char map [10] [10] { {wall, ' ', wall, wall,wall, wall,wall, wall,wall,wall},
{wall,' ', wall,' ', ' ',' ',' ', ' ', ' ',wall},
{wall,' ', wall,' ',wall,wall,wall,wall, ' ', wall},
{wall,' ',wall,' ',wall,' ',' ',' ',' ',wall},
{wall,' ',' ',' ',wall,wall,' ', wall,eat1 ,wall},
{wall,wall,wall,wall,wall,' ',' ',wall,wall,wall},
{wall,eat3,wall,' ',' ',' ',' ', ' ',eat2,wall },
{wall,' ',wall,' ',wall,' ',wall,wall,wall,wall},
{wall,' ',' ',' ',wall,' ',gate,' ',goal,wall},
{wall,wall,wall,wall,wall,wall,wall,wall,wall,wall}
};
char player = 'P';
cout<<"Star Remain : "<<star<<endl;
map[posy][posx] = player;
for (int i=0; i<=9;i++)
{
for (int j=0; j<=9;j++)
{
cout<<map[i][j];
}
cout<<endl;}
if(posx != 8 || posy != 8)
{char control = getch();
switch (control)
{case 's':
if (map [posy+1] [posx] != wall)
{posy++;}
break;
case 'w':
if (map [posy-1] [posx] != wall && posy >0)
{posy--;}
break;
case 'a':
if (map [posy] [posx-1] != wall)
{posx--;}
break;
case 'd':
if (map [posy] [posx+1] != wall && map [posy] [posx+1] != '|')
{
posx++;
}
break;
}
if (map [posy] [posx] == map [4][8] && eat1 != space)
{
star = star-1;
eat1 = space;
}
else if (map [posy] [posx] == map [6] [8] && eat2 !=space)
{
star = star-1;
eat2 = space;
}
else if (map [posy] [posx] == map [6] [1] && eat3 !=space)
{
star = star-1;
eat3 = space;
}
if (star == 0)
{
gate = space;
}
}
else cout<<"you win";
system ("cls");}
return 0;
}