-
Notifications
You must be signed in to change notification settings - Fork 0
/
CODE_VELHA.c
executable file
·360 lines (344 loc) · 9.53 KB
/
CODE_VELHA.c
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#include <Windows.h>
#include <stdio.h>
#define DIM 3
#define CARACTER 35
#define PLAYER2 79
#define PLAYER1 88
char Continuar(char conti);
char NomeCamp(char nome1[],char nome2[]);
int ExibirTab(char tabuleiro[][DIM]);
int Modificador(char nome1[],char nome2[]);
int VerCoordenadas(char Tab[][DIM],int a, int b);
int verCadaCoor(int a);
int verCampeao(char tab[][DIM],char N1[],char N2[],int count);
int MusicVitoria(char n1[],char n2[]);
int MusicEmpate(char n1[],char n2[]);
int main()
{
char nome1[30],nome2[30];
char conti;
do{
system("clear||cls");
NomeCamp(nome1,nome2);
Modificador(nome1,nome2);
printf("Querem batalhar novamente? \n");
printf("1- JOGAR\n0- sair\n");
printf("--->");
do{
scanf(" %c",&conti);
Continuar(conti);
}while(conti!='1'&&conti!='0');
}while(conti=='1');
return 0;
}
//Verificar ser os jogadores desejam continuar a jogar
char Continuar(char conti)
{
if(conti!='1'&&conti!='0'){
printf("Nao entendi a respostos...\n");
printf("Repita por favor...");
}
return conti;
}
//Nome dos Campe�es
char NomeCamp(char nome1[],char nome2[])
{
printf("\tENTRE COM O NOME DOS CAMPEOES\n");
printf("\nCAMPEAO 1 --> ");
scanf(" %30[^\n]",nome1);
printf("\nCAMPEAO 2 --> ");
scanf(" %30[^\n]",nome2);
return 1;
}
//EXIBIR TABULEIRO
int ExibirTab(char tabuleiro[][DIM])
{
int Linha,Coluna;
for(Linha=0;Linha<DIM;Linha++){
printf("\t");
for(Coluna=0;Coluna<DIM;Coluna++){
printf("%c ",tabuleiro[Linha][Coluna]);
}
printf("\n");
}
return 1;
}
//Modificador das posi�oes do tabuleiro
int Modificador(char nome1[],char nome2[])
{
int Linha,Coluna,count=0,L,C;
char tabuleiro[DIM][DIM];
//MONTAGEM DO TABULEIRO
for(Linha=0;Linha<DIM;Linha++){
for(Coluna=0;Coluna<DIM;Coluna++){
tabuleiro[Linha][Coluna]=CARACTER;
}
}
do{
count++;
system("clear || cls");
ExibirTab(tabuleiro);
//________________________________________
//============ENTRADA DO JOGADOR 1==================
if (count%2 != 0){
do{
//----------LINHA------------
printf("\n%s\n",nome1);
printf("Linha: ");
do{
scanf("%d",&L);
if(verCadaCoor(L)){
printf("Como? --> ");
}
}while(verCadaCoor(L));
--L;
//----------COLUNA------------
printf("Coluna: ");
do{
scanf("%d",&C);
if(verCadaCoor(L)){
printf("Como? --> ");
}
}while(verCadaCoor(C));
--C;
}while(VerCoordenadas(tabuleiro,L,C));
//----------------------------------
tabuleiro[L][C]=PLAYER1;
//=================================================
//===============ENTRADA DO JOGADOR 2=============
}else{
do{
//----------LINHA------------
printf("\n\n%s \n",nome2);
printf("Linha: ");
do{
scanf("%d",&L);
if(verCadaCoor(L)){
printf("Como? --> ");
}
}while(verCadaCoor(L));
--L;
//----------COLUNA------------
printf("Coluna: ");
do{
scanf("%d",&C);
if(verCadaCoor(L)){
printf("Como? --> ");
}
}while(verCadaCoor(C));
--C;
}while(VerCoordenadas(tabuleiro,L,C));
tabuleiro[L][C]=PLAYER2;
}
//=====================================================
printf("\n");
}while(verCampeao(tabuleiro,nome1,nome2,count));
//EXIBIR TABELA DA JOGADA FINAL
ExibirTab(tabuleiro);
return 1;
}
//Verifica��o das das entradas de coordenadas
int VerCoordenadas(char Tab[][DIM],int a, int b)
{
if (Tab[a][b]==CARACTER){
return 0;
}else{
printf("\nCasa ja foi marcada :)\n");
return 1;
}
}
//Verifica��o de cada coordenada
int verCadaCoor(int a)
{
if(a<1 || a>3){
return 1;
}else{
return 0;
}
}
//Verifica��o de linhas colunas e diagonais
int verCampeao(char tab[][DIM],char N1[],char N2[],int count)
{
//TESTE DE TODA A LINHA 0
if(tab[0][0]==PLAYER1&&tab[0][1]==PLAYER1&&tab[0][2]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[0][0]==PLAYER2&&tab[0][1]==PLAYER2&&tab[0][2]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DE TODA A LINHA 1
}else
if(tab[1][0]==PLAYER1&&tab[1][1]==PLAYER1&&tab[1][2]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[1][0]==PLAYER2&&tab[1][1]==PLAYER2&&tab[1][2]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DE TODA A LINHA 2
}else
if(tab[2][0]==PLAYER1&&tab[2][1]==PLAYER1&&tab[2][2]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[2][0]==PLAYER2&&tab[2][1]==PLAYER2&&tab[2][2]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DE TODA A COLUNA 0
}else
if(tab[0][0]==PLAYER1&&tab[1][0]==PLAYER1&&tab[2][0]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[0][0]==PLAYER2&&tab[1][0]==PLAYER2&&tab[2][0]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DE TODA A COLUNA 1
}else
if(tab[0][1]==PLAYER1&&tab[1][1]==PLAYER1&&tab[2][1]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[0][1]==PLAYER2&&tab[1][1]==PLAYER2&&tab[2][1]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DE TODA A COLUNA 2
}else
if(tab[0][2]==PLAYER1&&tab[1][2]==PLAYER1&&tab[2][2]==PLAYER1){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else if(tab[0][2]==PLAYER2&&tab[1][2]==PLAYER2&&tab[2][2]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//TESTE DAS DIAGONAIS
}else
if(tab[0][0]==PLAYER1&&tab[1][1]==PLAYER1&&tab[2][2]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else
if(tab[0][0]==PLAYER2&&tab[1][1]==PLAYER2&&tab[2][2]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
}else
if(tab[0][2]==PLAYER1&&tab[1][1]==PLAYER1&&tab[2][0]==PLAYER1){
MusicVitoria(N1,N2);
printf("O player %s VENCEUUUUUU\n",N1);
return 0;
}else
if(tab[0][2]==PLAYER2&&tab[1][1]==PLAYER2&&tab[2][0]==PLAYER2){
MusicVitoria(N2,N1);
printf("O player %s VENCEUUUUUU\n",N2);
return 0;
//Empate...........
}else if(count >= 9){
MusicEmpate(N1,N2);
printf("O jogo entre os campeoes %s e %s deu EMPATE!!!\n",N1,N2);
return 0;
}
return 1;
}
//MUSICA PARA A VITORIA
int MusicVitoria(char n1[],char n2[])
{
//PRIMEIRA ESTROFE
printf("\n\tO campeao\n");
Beep(330,200);
Beep(396,200);
Beep(440,200);
Beep(440,470);
printf("\t%s\n",n1);
Beep(440,200);
Beep(495,200);
Beep(528,200);
Beep(528,470);
printf("\tVenceuu \n");
Beep(528,200);
Beep(297,200);
Beep(495,200);
Beep(495,470);
printf("\tA partida!\n\n");
Beep(440,200);
Beep(396,200);
Beep(396,200);
Beep(440,200);
Beep(0,200);
//SEGUNDA ESTROFE
printf("\tE o campeaoo\n");
Beep(330,200);
Beep(396,200);
Beep(440,200);
Beep(440,470);
printf("\t%s\n",n2);
Beep(440,200);
Beep(495,200);
Beep(528,200);
Beep(528,470);
printf("\tEh um bosta\n");
Beep(528,200);
Beep(297,200);
Beep(495,200);
Beep(495,470);
printf("\tNa sua vida\n\n");
Beep(440,200);
Beep(396,200);
Beep(440,200);
Beep(0,200);
return 0;
}
//MUSICA NO CASO DE EMPATE
int MusicEmpate(char n1[],char n2[])
{
printf("\n\tACABOOO\n");
Beep(396,240);
Beep(330,240);
Beep(256,1000);
Beep(0,100);
printf("\tO jogooo...\n");
Beep(330,350);
Beep(396,350);
Beep(440,1050);
Beep(330,800);
Beep(0,150);
printf("\tEEEEEE\n");
Beep(396,1000);
printf("\tO jogo empatoooo\n\n");
Beep(360,270);
Beep(396,270);
Beep(440,270);
Beep(297,270);
Beep(495,1000);
Beep(440,600);
Beep(0,250);
//rep
printf("\t%s e %s\n",n1,n2);
Beep(396,340);
Beep(330,340);
Beep(256,1000);
Beep(0,100);
printf("\tVoces saooooo\n");
Beep(330,350);
Beep(396,350);
Beep(440,1050);
printf("\tRUUIIM\n");
Beep(330,800);
Beep(0,150);
printf("\tE merecem \n");
Beep(396,1000);
Beep(360,270);
Beep(396,270);
Beep(440,270);
Beep(297,270);
printf("\tMorrer...\n\n");
Beep(330,1100);
return 0;
}