-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPIANOTIL.CPP
More file actions
302 lines (292 loc) · 5.42 KB
/
PIANOTIL.CPP
File metadata and controls
302 lines (292 loc) · 5.42 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<time.h>
#include<bios.h>
#include<stdio.h>
union REGS km,o;
int x[4]={60,146,232,318},s,P=0,N=0,d,m,b[4]={0,0,0,0},a[4]={0,1,2,3},z[4]={0,0,0,0},y[4]={0,-80,-160,-240};
void input()
{
int k=0,k1,k2,kk,k3;
int la=z[0]*10+y[0],sl,tl,fl;
for(s=0;s<4;s++)
if(la<=z[s]*10+y[s] )
{ la=z[s]*10+y[s];
k=s; }
kk=k;
if(b[k]==7 || b[k]==4){
for(s=0;s<4;s++)
{
if(k!=s){
sl=z[s]*10+y[s];
break;
} }
for(s=0;s<4;s++) {
if((10*z[s]+y[s])>=sl && (z[s]*10+y[s])<la)
{
sl=z[s]*10+y[s];
k1=s;
}
}
kk=k1;
}
if((b[k1]==7 || b[k1]==4) && ( b[k]==7 || b[k]==4)){
for(s=0;s<4;s++)
{
if(k!=s && k1!=s){
tl=z[s]*10+y[s];
break;
}
}
for(s=0;s<4;s++) {
if((10*z[s]+y[s])>=tl && (z[s]*10+y[s])<sl)
{
tl=z[s]*10+y[s];
k2=s;
}
}
kk=k2;
}
if((b[k1]==7 || b[k1]==4) && ( b[k]==7 || b[k]==4) && (b[k2]==7 || b[k2]==4))
{
for(s=0;s<4;s++)
if(s!=k1 && s!=k2 && s!=k)
k3=s;
kk=k3;
}
o.h.ah=0;
int86(22,&km,&o);
if(o.h.ah==1)
{
exit(0);
closegraph();
}
else if(o.h.ah==72)
{
if(a[kk]==0 ){
b[kk]=7;
P=P+1;
}
else if(a[kk]!=0)
{
b[kk]=4;
N=N+1;
}
}
else if(o.h.ah==80)
{
if(a[kk]==2){
b[kk]=7;
P=P+1;
}
else if(a[kk]!=2)
{
b[kk]=4;
N=N+1;
}
}
else if(o.h.ah==77)
{
if(a[kk]==3){
b[kk]=7;
P=P+1;
}
else if(a[kk]!=3)
{
b[kk]=4;
N=N+1;
}
}
else if(o.h.ah==75)
{
if(a[kk]==1){
b[kk]=7;
P=P+1;
}
else if(a[kk]!=1)
{
b[kk]=4;
N=N+1;
}
}
}
void main()
{
char c,C[2],NA[20];
int o,aa;
time_t t,T,tt;
clrscr();
cout<<" Welcome to Piano Tiles Game \n";
cout<<" Enter your name : \n";
gets(NA);
cout<<" Choose your level : \n";
cout<<" 1.Champion \n 2. Hard \n 3. Easy\n";
do{
cin>>aa;
if(aa!=1 && aa!=2 && aa!=3)
cout<<" Wrong input!!!!!!!!!!\n Re-Enter your choice :\n";
}while(aa!=1 && aa!=2 && aa!=3);
cout<<" Press R to read rules : \n";
cout<<" OR Press any alphabet to Start: \n";
cin>>c;
if(c=='R' || c=='r'){
cout<<"\n 1. You have to press direction arrows according to \n the written directions on the box. \n";
cout<<"\n 2. You can do a mistake in every 6 tiles.......... but\n have to do 2 mistakes in every 10 Tiles .\n " ;
cout<<"\n 3. Times in seconds decide your concentration quotient.\n ";
getch();
}
t=time(NULL);
int gdriver=9,gmode=2,error,i,j,k,l=0;
initgraph(&gdriver,&gmode,"C:\\tc\\bgi") ;
error=graphresult();
if(error!=grOk){
cout<<" There is some error in opening of this file \n";
cout<<" Error is :"<<grapherrormsg(error);
getch();
exit(1);}
setfillpattern("11111111",9);
bar(420,0,639,80);
setfillpattern("11111111",14);
bar(599,0,639,479);
setfillpattern("11111111",4);
bar(420,399,639,479);
setcolor(14);
for(i=0;i<61;i++) {
line(i,0,i,80);
line(360+i,0,360+i,80);}
setcolor(9);
for(i=0;i<61;i++) {
line(i,399,i,479);
line(360+i,399,360+i,479);}
for(i=0;i<16;i++){
if((i%2)==1)
setcolor(7);
if((i%2)==0)
setcolor(0);
for(j=0;j<20;j++)
line(0,80+20*i+j,60,+j+80+20*i);
for(j=0;j<20;j++)
line(360,80+20*i+j,420,+j+80+20*i);
}
for(i=0;i<7;i++){
if((i%2)==1)
setcolor(0);
if((i%2)==0)
setcolor(7);
for(j=0;j<43;j++)
line(60+43*i+j,0,60+43*i+j,80);
if((i%2)==1)
setcolor(4);
for(j=0;j<43;j++)
line(60+43*i+j,399,60+43*i+j,479); }
setcolor(7);
for(k=60;k<361;k++)
line(k,80,k,399);
do {
T=time(NULL);
for(m=0;m<4;m++){
setcolor(b[m]);
for(k=0;k<43;k++)
line(x[m]+k,y[m]+10*(z[m]),x[m]+k,y[m]+10*z[m]+80);
setcolor(9);
settextstyle(0,0,2);
outtextxy(422,130,"PIANO TILES ");
setcolor(4);
settextstyle(0,0,0);
outtextxy(430,200,"Correct Responses:");
setcolor(14);
C[0]=48+P;
C[1]=32;
outtextxy(574,200,C);
setcolor(0);
bar(585,200,600,215);
setcolor(14);
outtextxy(430,260,"Wrong Responses:");
C[0]=48+N;
C[1]=32;
setcolor(4);
outtextxy(560,260,C);
setcolor(0);
bar(570,260,600,275);
setcolor(14);
outtextxy(455,300," Level ");
C[0]=48+aa;
C[1]=32;
setcolor(12);
outtextxy(525,300,C);
setcolor(0);
bar(540,300,600,315);
settextstyle(0,0,2);
setcolor(9);
outtextxy(460,350,NA);
if((P+N)<=6){
if(N>=2) {
closegraph();
cout<<" Your score is :"<<T-t;
getch();
}
}
else if((P+N)>=10)
{
if(N<2)
{
closegraph();
cout<<" Your score is :"<<T-t;
getch();
}
else {
N=0;
P=0;
}
}
settextstyle(0,0,0);
if(a[m]==0){
setcolor(4);
outtextxy(x[m]+16,y[m]+10*z[m]+40,"UP");
}
else if(a[m]==3){
setcolor(9);
outtextxy(x[m],y[m]+10*z[m]+40,"RIGHT");
}
else if(a[m]==1){
setcolor(14);
outtextxy(x[m]+4,y[m]+10*z[m]+40,"LEFT");
}
else if(a[m]==2){
setcolor(2);
outtextxy(x[m]+4,y[m]+10*z[m]+40,"DOWN");
}
if((y[m]+10*(z[m]+1)+80)>=399)
{
tt=time(NULL);
a[m]=tt%4;
y[m]=0;
z[m]=0;
x[m]=60+43*a[m]*2;
b[m]=0;
}
if(bioskey(1)!=0)
input();
delay(7-(3-aa)*2);
z[m]++;
setcolor(7);
for(k=0;k<43;k++) {
if((y[m]+10*z[m])>40)
line(x[m]+k,0,x[m]+k,80);
line(x[m]+k,399,x[m]+k,479);
}
}
delay(25-(3-aa)*4);
setfillpattern(0,0);
setcolor(0);
bar(420,80,599,399);
setcolor(7);
for(k=60;k<361;k++)
line(k,80,k,399);
}while(1);
getch();
closegraph();
}