Pascal/Turbo Pascal - necesito este juego y no se como hacerlo

 
Vista:
sin imagen de perfil

necesito este juego y no se como hacerlo

Publicado por mario (10 intervenciones) el 29/10/2016 02:21:09
hola necesito un juego que te permita jugar al ta te ti en pascal, si me ayudan por favor , que no se como hacerlo, desde ya muchas gracias por su tiempo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

necesito este juego y no se como hacerlo

Publicado por David (224 intervenciones) el 29/10/2016 21:35:00
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
Program Tateti;
Uses Crt;
var I: Integer;
Tecla1, Tecla2 : Char;
Procedure DibujaCuadro; {Dibuja el marco para comenzar a jugar}
begin
ClrScr;
Writeln;
for I := 1 to 5 do
Writeln(' Û Û');
Writeln(' ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ');
for I := 1 to 5 do
Writeln(' Û Û');
Writeln(' ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ');
for I := 1 to 5 do
Writeln(' Û Û');
GotoXY(10,1); Write('1'); GotoXY(26,1); Write('2');
GotoXY(45,1); Write('3'); GotoXY(10,8); Write('4');
GotoXY(26,8); Write('5'); GotoXY(45,8); Write('6');
GotoXY(10,15); Write('7'); GotoXY(26,15); Write('8');
GotoXY(45,15); Write('9');
end;{DibujaCuadro}
{Dibuja la letra X o la letra O segun el usuario}
{PosX significa Poscicion X}
{Los segmentos en blanco son para borrar alguna letra dibujada anteriormente}
Procedure DibujaXO(PosX, PosY: Integer; XuO: Char);
begin
if XuO = 'X' then {Puse XuO para no decir: X o O por eso de la gramatica}
begin
GotoXY(PosX, PosY); write(' ');
GotoXY(PosX, PosY+1); write(' ');
GotoXY(PosX, PosY+2); write(' ');
GotoXY(PosX, PosY+3); write(' ');
GotoXY(PosX, PosY+4); write(' ');
GotoXY(PosX, PosY); write(' Û Û ');
GotoXY(PosX, PosY+1); write(' Û Û ');
GotoXY(PosX, PosY+2); write(' Û ');
GotoXY(PosX, PosY+3); write(' Û Û ');
GotoXY(PosX, PosY+4); write(' Û Û ');
end;
if XuO ='O' then
begin
GotoXY(PosX, PosY); write(' ');
GotoXY(PosX, PosY+1); write(' ');
GotoXY(PosX, PosY+2); write(' ');
GotoXY(PosX, PosY+3); write(' ');
GotoXY(PosX, PosY+4); write(' ');
GotoXY(PosX, PosY); write(' ÛÛÛÛÛ ');
GotoXY(PosX, PosY+1); write(' Û Û ');
GotoXY(PosX, PosY+2); write(' Û Û ');
GotoXY(PosX, PosY+3); write(' Û Û ');
GotoXY(PosX, PosY+4); write(' ÛÛÛÛÛ ');
end;
end;{DibujaXO}
begin
DibujaCuadro;
GotoXY(20,21); Writeln('Para salir presione ESC');
While Tecla2 <> Char(27) do {Char(27) es la tecla ESC}
begin
GotoXY(20,20); write(' ');
GotoXY(20,20); write('Presione X u O : ');
{Upcase(ReadKey) convierte la tecla presionada en mayuscula}
Tecla1 := UpCase(ReadKey);
{Halt detiene el programa. Yo no deberia hacer esto asi.}
if Tecla1 = char(27) then Halt;{Halt termina el programa. No se debe}
GotoXY(20,20); write(' ');
GotoXY(20,20); write('Presione N£mero de posici¢n: ');
{Tecla2 almacena el numero de posicion aunque este numero es una letra}
Tecla2 := ReadKey; {Recuerda que Tecla1 y Tecla2 son de tipo char}
if Tecla2 = '1'then DibujaXO(12,1,Tecla1);
if Tecla2 = '2'then DibujaXO(30,1,Tecla1);
if Tecla2 = '3'then DibujaXO(48,1,Tecla1);
if Tecla2 = '4'then DibujaXO(12,8,Tecla1);
if Tecla2 = '5'then DibujaXO(30,8,Tecla1);
if Tecla2 = '6'then DibujaXO(48,8,Tecla1);
if Tecla2 = '7'then DibujaXO(12,15,Tecla1);
if Tecla2 = '8'then DibujaXO(30,15,Tecla1);
if Tecla2 = '9'then DibujaXO(48,15,Tecla1);
end;{Principal}
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

necesito este juego y no se como hacerlo

Publicado por ramon (2158 intervenciones) el 31/10/2016 23:26:48
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
{Mira esto a ver si te ayuda }
 
 program ta_te_ti;
  uses
    crt;
    const
      tablero : array[1..7,1..7] of char = (
      (#218,#196,#194,#196,#194,#196,#191),
      (#179,#32,#179,#32,#179,#32,#179),
      (#195,#196,#197,#196,#197,#196,#180),
      (#179,#32,#179,#32,#179,#32,#179),
      (#195,#196,#197,#196,#197,#196,#180),
      (#179,#32,#179,#32,#179,#32,#179),
      (#192,#196,#193,#196,#193,#196,#217));
 
     type
 
        jugadores = record
             nombre : string[50];
             table : array[1..3,1..3] of char;
             end;
 
    var
      juego : array[1..2] of jugadores;
      prim, cont, turno, pos1x, pos1y : integer;
      jugad1, jugad2 : boolean;
 
 
    procedure pontablero(x, y, tur : integer);
    var
      h, k : integer;
     begin
         gotoxy(x - 1,y + 2);write('1');
         gotoxy(x - 3,y + 4);write('Y 2');
         gotoxy(x - 1,y + 6);write('3');
         gotoxy(x + 2,y - 1);write('1');
         gotoxy(x + 4,y - 3);write('X');
         gotoxy(x + 4,y - 1);write('2');
         gotoxy(x + 6,y - 1);write('3');
         gotoxy(x + 1,y - 5);write('Tablero Termina Juego [ESC]');
         for h := 1 to 7 do
           for k := 1 to 7 do
           begin
           gotoxy(x + h,y + k);write(tablero[k,h]);
           end;
           gotoxy(x,y + 9);write('Inicia Juego El Jugador ');
           gotoxy(x,y + 11);write('Jugador [X] Nombre = ');
           gotoxy(x + 21,y + 11);write(juego[1].nombre);
           gotoxy(x,y + 13);write('Jugador [O] Nombre = ');
           gotoxy(x + 21,y + 13);write(juego[2].nombre);
           if tur = 1 then
           begin
           textcolor(14);
           gotoxy(x + 21,y + 11);write(juego[tur].nombre);
           textcolor(7);
           end
        else
          begin
          textcolor(14);
           gotoxy(x + 21,y + 13);write(juego[tur].nombre);
           textcolor(7);
          end;
     end;
 
     procedure presentapartida(xp, yp : integer);
     var
       xx, yy : integer;
       begin
          for yy := 1 to 3 do
          begin
            for xx := 1 to 3 do
            begin
               if juego[1].table[xx,yy] <> #0 then
                begin
          gotoxy(xp + (xx * 2),yp + (yy * 2));write(juego[1].table[xx,yy]);
                  end
               else
                  begin
                    gotoxy(xp + (xx * 2),yp + (yy * 2));write(' ');
                  end;
               if juego[2].table[xx,yy] <> #0 then
               begin
          gotoxy(xp + (xx * 2),yp + (yy * 2));write(juego[2].table[xx,yy]);
           end
         else
            begin
              gotoxy(xp + (xx * 2),yp + (yy * 2));write(' ');
            end;
          end;
         end;
       end;
 
  function correctojuego(n : integer) : boolean;
  var
    ok : boolean;
    cc : char;
    begin
       if n = 1 then
       cc := 'X';
       if n = 2 then
       cc := 'O';
       ok := false;
       if (juego[n].table[1,1] = cc) and
          (juego[n].table[2,1] = cc) and
          (juego[n].table[3,1] = cc) then
          ok := true;
        if (juego[n].table[1,2] = cc) and
          (juego[n].table[2,2] = cc) and
          (juego[n].table[3,2] = cc) then
          ok := true;
        if (juego[n].table[1,3] = cc) and
          (juego[n].table[2,3] = cc) and
          (juego[n].table[3,3] = cc) then
          ok := true;
         if (juego[n].table[1,1] = cc) and
          (juego[n].table[1,2] = cc) and
          (juego[n].table[1,3] = cc) then
          ok := true;
        if (juego[n].table[2,1] = cc) and
          (juego[n].table[2,2] = cc) and
          (juego[n].table[2,3] = cc) then
          ok := true;
        if (juego[n].table[3,1] = cc) and
          (juego[n].table[3,2] = cc) and
          (juego[n].table[3,3] = cc) then
          ok := true;
        if (juego[n].table[1,1] = cc) and
          (juego[n].table[2,2] = cc) and
          (juego[n].table[3,3] = cc) then
          ok := true;
        if (juego[n].table[3,1] = cc) and
          (juego[n].table[2,2] = cc) and
          (juego[n].table[1,3] = cc) then
          ok := true;
       correctojuego := ok;
    end;
 
 
 
  procedure iniciojuego(var juega : integer);
  var
    p : integer;
  begin
     gotoxy(20,4);write('Entre Nombre Jugador [1] = ');
     gotoxy(47,4);readln(juego[1].nombre);
     gotoxy(20,4);clreol;
     gotoxy(20,4);write('Entre Nombre Jugador [2] = ');
     gotoxy(47,4);readln(juego[2].nombre);
     gotoxy(20,4);clreol;
     p := random(40) + 1;
       case p of
  1,3,5,7,9 : juega := 1;
  2,4,6,8,10 : juega := 2;
  11,13,15,17,19 : juega := 1;
  12,14,16,18,20 : juega := 2;
  21,23,25,27,29 : juega := 2;
  22,24,26,28,30 : juega := 1;
  31,33,35,37,39 : juega := 2;
  32,34,36,38,40 : juega := 1;
     end;
     pontablero(10,7,juega);
     presentapartida(10,7);
  end;
 
 
 
  procedure movemosfichas(j : integer);
  var
     ju1x, ju1y, ju, mue : integer;
     valido : boolean;
     sig, tecla : char;
     ganador : string[50];
  begin
     ju := j;
     valido := true;
     mue := 1;
     ganador := ' ';
     repeat
        gotoxy(40,7);clreol;
        gotoxy(40,8);clreol;
        if ju = 1 then
        begin
           gotoxy(31,20);write(juego[2].nombre);
           textcolor(14);
           gotoxy(31,18);write(juego[1].nombre);
           textcolor(7);
           gotoxy(40,7);write('Entre Cordenada [X] : ');
           repeat
           tecla := readkey;
           until tecla in['1','2','3',#27];
           if tecla = #27 then
           break;
           gotoxy(62,7);write(ord(tecla) - 48);
           ju1x := ord(tecla) - 48;
           gotoxy(40,8);write('Entre Cordenada [Y] : ');
           repeat
           tecla := readkey;
           until tecla in['1','2','3',#27];
           if tecla = #27 then
           break;
           gotoxy(62,8);write(ord(tecla) - 48);
           ju1y := ord(tecla) - 48;
           gotoxy(40,7);clreol;
           gotoxy(40,8);clreol;
           if juego[1].table[ju1x,ju1y] <> #0 then
           begin
              valido := false;
           end
         else
           begin
           juego[1].table[ju1x,ju1y] := 'X';
           juego[2].table[ju1x,ju1y] := 'X';
           ju := ju + 1;
           valido := true;
           mue := mue + 1;
           presentapartida(10,7);
           if correctojuego(1) = true then
           begin
           ganador := copy(juego[1].nombre,1,length(juego[1].nombre));
           break;
           end;
         end;
        end;
        if ju = 2 then
        begin
           gotoxy(31,18);write(juego[1].nombre);
           textcolor(14);
           gotoxy(31,20);write(juego[2].nombre);
           textcolor(7);
           gotoxy(40,7);write('Entre Cordenada [X] : ');
           repeat
           tecla := readkey;
           until tecla in['1','2','3',#27];
           if tecla = #27 then
           break;
           gotoxy(62,7);write(ord(tecla) - 48);
           ju1x := ord(tecla) - 48;
           gotoxy(40,8);write('Entre Cordenada [Y] : ');
           repeat
           tecla := readkey;
           until tecla in['1','2','3',#27];
           if tecla = #27 then
           break;
           gotoxy(62,8);write(ord(tecla) - 48);
           ju1y := ord(tecla) - 48;
           if juego[2].table[ju1x,ju1y] <> #0 then
           begin
              valido := false;
           end
         else
           begin
           juego[2].table[ju1x,ju1y] := 'O';
           juego[1].table[ju1x,ju1y] := 'O';
           ju := ju - 1;
           valido := true;
           mue := mue + 1;
           presentapartida(10,7);
           if correctojuego(2) = true then
           begin
           ganador := copy(juego[2].nombre,1,length(juego[2].nombre));
           break;
           end;
         end;
        end;
     if valido = true then
     begin
     valido := false;
     gotoxy(40,9);clreol;
     end
   else
      begin
        gotoxy(40,9);write('Celda Ocupada');
      end;
     until mue >= 7;
     presentapartida(10,7);
     if ju = 1 then
     ju := ju + 1;
     if ju = 2 then
     ju := ju - 1;
     if (ganador <> juego[2].nombre) or (ganador <> juego[1].nombre) then
     begin
         ganador := ' ';
         gotoxy(40,7);clreol;
         gotoxy(40,8);clreol;
         presentapartida(10,7);
       repeat
         if ju = 1 then
         begin
           gotoxy(31,20);write(juego[2].nombre);
           textcolor(14);
           gotoxy(31,18);write(juego[1].nombre);
           textcolor(7);
         end;
         if ju = 2 then
         begin
           gotoxy(31,20);write(juego[1].nombre);
           textcolor(14);
           gotoxy(31,18);write(juego[2].nombre);
           textcolor(7);
         end;
         gotoxy(30,7);clreol;
         gotoxy(30,8);clreol;
         gotoxy(30,7);write('Entre Cordenadas [X] De Ficha A Mover : ');
         repeat
            tecla := readkey;
         until tecla in['1','2','3',#27];
         if tecla = #27 then
         break;
         ju1x := ord(tecla) - 48;
         gotoxy(30,8);write('Entre Cordenadas [Y] De Ficha A Mover : ');
         repeat
            tecla := readkey;
         until tecla in['1','2','3',#27];
         if tecla = #27 then
         break;
         ju1y := ord(tecla) - 48;
         gotoxy(30,7);clreol;
         gotoxy(30,8);clreol;
         case ju of
      1 : sig := 'X';
      2 : sig := 'O';
        end;
         if juego[ju].table[ju1x,ju1y] = sig then
         begin
            juego[ju].table[ju1x,ju1y] := #0;
            if ju = 1 then
            juego[ju + 1].table[ju1x,ju1y] := #0;
            if ju = 2 then
            juego[ju - 1].table[ju1x,ju1y] := #0;
            gotoxy(30,7);clreol;
            gotoxy(30,8);clreol;
            presentapartida(10,7);
            gotoxy(30,7);write('Entre Cordenadas [X] De Nueva Posicion : ');
            repeat
            tecla := readkey;
            until tecla in['1','2','3',#27];
            if tecla = #27 then
            break;
            ju1x := ord(tecla) - 48;
            gotoxy(30,8);write('Entre Cordenadas [Y] De Nueva Posicion : ');
            repeat
            tecla := readkey;
            until tecla in['1','2','3',#27];
            if tecla = #27 then
            break;
            ju1y := ord(tecla) - 48;
            gotoxy(30,7);clreol;
            gotoxy(30,8);clreol;
            if juego[ju].table[ju1x,ju1y] = #0 then
            if sig = 'X' then
            begin
            juego[ju].table[ju1x,ju1y] := 'X';
            if ju = 1 then
            juego[ju + 1].table[ju1x,ju1y] := 'X';
            if ju = 2 then
            juego[ju - 1].table[ju1x,ju1y] := 'X';
            end;
            if sig = 'O' then
            begin
            juego[ju].table[ju1x,ju1y] := 'O';
            if ju = 1 then
            juego[ju + 1].table[ju1x,ju1y] := 'O';
            if ju = 2 then
            juego[ju - 1].table[ju1x,ju1y] := 'O';
            end;
            presentapartida(10,7);
 
            if correctojuego(ju) = true then
           begin
           ganador := copy(juego[ju].nombre,1,length(juego[ju].nombre));
           break;
           end;
         end;
          if ju = 1 then
          ju := 2
        else
          ju := 1;
      until (ganador <> ' ') or (tecla = #27);
     end;
     if (ganador = juego[2].nombre) or (ganador = juego[1].nombre) then
     begin
     clrscr;
     writeln;
     writeln('   El Ganador Fue = ',ganador);
     writeln;
     writeln('   Pulse Una Tecla');
     readkey;
     end;
  end;
 
 
 
     begin
        clrscr;
        turno := 0;
        fillchar(juego[1],sizeof(juego[1]),#0);
        fillchar(juego[2],sizeof(juego[2]),#0);
        randomize;
        iniciojuego(turno);
        movemosfichas(turno);
     end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar