RE:programa del juego la vieja
Emiro. No he tenido mucho tiempo pero te envío lo que llevo de tu programa, pues todavía le falta..
Por favor analízalo y si puedes trata de terminarlo o modificarlo pues sabemos que todos pensamos de forma diferente a la hora de programar.
Avísame si quieres más comentarios para su mejor comprensión.
Suerte!
(* E siguiente programa es el juego de la Vieja. Aun en costruccion*)
(* Willy de Leon. Guatemala 20 de junio de 2007. Turbo Pascal 7 *)
Program Vieja;
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.