help..

this is code for a game in which one star moves with specified controle when it reach a specified point then msg come "you win".this is only one player i want to make it for two playr two star moves with dfrent contorle .the star whch reach 1st .it win.i made one player.plzzzzzzzzzz help mme to make it two player.from which point i satrt code for 2nd player in this program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  #include<iostream>
#include<Windows.h>
#include<conio.h>
using namespace std;

void gotoXY(int x, int y)
{
	 COORD coord = {x, y};
	 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
	 return;
}
	int main()
	{
		system("color B3");
		gotoXY(40,13);
			cout<<"|_|";
		int i=0;
		int j=0;
		char c;
		int a=0;
while(true)
{
	if(_kbhit())
	{
		c=_getch();
		a=c;
	}
	if(a==68)
	{
gotoXY(i,j);
Sleep(50);
cout<<"*";
Sleep(50);
gotoXY(i,j);
cout<<" ";
i++;
i=i%80;
	}
	else if(a==65)
{
gotoXY(i,j);
Sleep(50);
cout<<"*";
Sleep(50);
gotoXY(i,j);
cout<<" ";
i--;
i=i+80;
i=i%80;
}
else if(a==83)
{
	gotoXY(i,j);
Sleep(50);
cout<<"*";
Sleep(50);
gotoXY(i,j);
cout<<" ";
j++;
j=j%25;
}
else if(a==87)
{
		gotoXY(i,j);
Sleep(50);
cout<<"*";
Sleep(50);
gotoXY(i,j);
cout<<" ";
j--;
j=j+25;
j=j%25;
}
if((i==40&&j==13)||(i==41&&j==13))
	break;
}
cout<<"you win"<<endl;
	return 0;
	}
Topic archived. No new replies allowed.