-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.cpp
107 lines (106 loc) · 2.51 KB
/
player.cpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include"player.h"
player::player()
{
size=50;
p=new char[size];
for(int i=0; i<size ; i++ )
p[i]='0';
}
void player::setUnique_ID(int i)
{
Unique_ID=i;
}
int player::getUnique_ID()const
{
return Unique_ID;
}
void player::setName(char A)
{
for(int i=0; i<size ; i++)
{
if(p[i]=='0')
{
p[i]=A;
return;
}
}
}
void player::TakeInputandDisplay()
{
glClearColor( 1 , 1 , 1 , 1);
glClear (GL_COLOR_BUFFER_BIT);
DrawRoundRect(-10,-10,1040,30,colors[BLACK]);
DrawRoundRect(-10,-10,30,850,colors[BLACK]) ;
DrawRoundRect(-10,820,1040,30,colors[BLACK]);
DrawRoundRect(1000,-10,30,870,colors[BLACK]);
int x1=385, y1=340;
DrawRectangle(380,380,200,60,colors[BLACK]);
DrawString(400,400, "ENTER NAME",colors[RED]);
for(int i=0 ; i<size ; i++)
{
if(p[i]!='0')
{
string s="a";
s[0]=p[i];
DrawRectangle(x1-5,y1-20,30,60,colors[BLACK]);
DrawString(x1,y1,s,colors[RED]);
x1+=22;
}
else
break;
}
DrawRectangle(380,80,250,60,colors[BLACK]);
DrawString(400,100, "ENTER '1' TO SAVE",colors[RED]);
glutSwapBuffers();
glutPostRedisplay();
}
void player::DisplayPlayerInfo()
{
glClearColor(1/*Red Component*/, 1, //148.0/255/*Green Component*/,
1/*Blue Component*/, 1 /*Alpha component*/); // Red==Green==Blue==1 --> White Colour
glClear (GL_COLOR_BUFFER_BIT);
DrawRectangle(100,200,700,500,colors[RED]);
DrawRectangle(120,220,660,460,colors[BLACK]);
int x1=500;
DrawString(200,600,"PLAYER NAMES:: ",colors[RED]);
for(int i=0 ; i<size ; i++)
{
if(player::p[i]!='0')
{
string s="a";
s[0]=p[i];
DrawString(x1,600,s,colors[RED]);
x1+=16;
}
else
break;
}
DrawString(200,560,"UNIQUE ID ",colors[RED]);
string c=Num2Str(Unique_ID);
DrawString(500,560,c,colors[RED]);
DrawString(200,300,"PRESS B TO BACK TO MANU ",colors[RED]);
glutSwapBuffers();
glutPostRedisplay();
}
// this will save name of player on each time a game is started
void player::saveName()
{
Unique_ID = GetRandInRange(0,9999);
ofstream Name("PlayerName.txt", ios::app);
for(int i=0 ; i<size ; i++ )
{
if(p[i]!='0')
{
Name<<p[i];
}
else
break;
}
Name<<endl;
Name.close();
return;
}
player::~player()
{
delete []p;
}