Contenido del código de programación de minijuegos
# incluir ltstdlib.h gt
# incluir ltconio.h gt
# incluir ltgraphics.h gt
#Definición HH '0 '
#Definición N 6
int Q = 0
char key
int fine = 1; ;
int A=0, B = 0;
char s[N][N], m[N][N];
void * bola;
int maxx
Tamaño int sin signo;
Cargando()
{ int z = 1;
Blanco(z)
{ if(z gt; 77) roto
printf("lt);
Retraso (5000); p>
z ;
}
Retraso(2000);
borrar dispositivo();
}
Carácter sin firmar Get_Ascii_Key(void)
{
if(bioskey(1))
return(clave BIOS(0 )); p>
De lo contrario, devuelve (0);
}
int test_ascii_key(int ascii)
{
if(Get_Ascii_Key ()==ascii)
Retorno(1);
Otros
retorno(0);
p>
}
void tu(){
maxx = get maxx();
tamaño=tamañoimagen(210, 390, 450, 420 ); >
bola=malloc(tamaño);
setfillstyle(1, 10
Bar(160, 170, 473, 253); p>setfillstyle(1,9);
Bar(163,173,470,250);
establecer color(13);
outtextxy(200, 200, "Bienvenido a Blanco y negro");
establecer color(14);
outtextxy(250, 220, "Desarrollador: Wu Siyuan") ;
outtextxy(290 , 240, "2002.8");
outtextxy(210, 390, "Presione cualquier tecla para continuar...");
getimage(210, 390, 450, 420, bola);
Y (! kbhit()){
putimage(210, 390, bola, XOR _ PUT>
Retraso (30000);
}
borrar dispositivo();
}
void sou(void){
}
Void print() p >
{ int i=0, j = 30
establecer color(11);
outtextxy(35, 20, " 0 1 2 3 4 5 "); /p>
outtextxy(14, 50, " 0 ");
>outtextxy(14,100,"1");
outtextxy(14,150,"2");
outtextxy(14200,"3");
outtextxy (14,250," 4");
out textxy(14300, "5");
setbkcolor(0);
setlinestyle(SOLID_LINE, 0, 2);
for(I = 0;ilt7;i)
{ setcolor(verde);
Línea( j, 30, j, 330)
j = 50
}
j = 30
para(I = 0 ;ilt7;i )
{ setcolor(verde);
línea(30,j,330,j);
j = 50;
p>
}
for(I = 0;i lt6;i)
for(j = 0;j lt6;j)
{ si(s[ i][j]=='o ')
{
setcolor(blanco);
círculo (55 j*50, 55 i*50, 15);
}
else if(s[i][j]=='x ')
{ setcolor(rojo) ;
Círculo (55 j*50, 55 i*50, 15);}
}
}
Calibración interna (Carácter z)
{ int * p = 0;
int num=0, I, j
for(I = 0; i ltn; i )
for(j = 0; j ltn; j )
if(s[I][j]= = z)num;
p = ampnum
return(* p);
}
Guardar no válido()
{int i, j;
para (I = 0;i ltn;i)
for(j = 0;j ltn;j)
m[I][j]= s[I ][j] ;
}
Carga no válida()
{ int i, j;
for(I = 0; i ltn; i )
for(j = 0; j ltn; j )
s[I][j]= m[I][j];
}
snew(int x, int y, char z1, char z2)
{int i, j, a; int can[]={0, 0, 0, 0, 0, 0, 0, 0}, k[N * N];
if(s[x][y-1]= = z 1 amp; amp(y-1) >=0)
{
I = 0;
mientras(I lty)
{
si(s[ x][I]= = z2){ can[1]= 1; romper;}
i;
}
}
if(s[x][y 1]==z1)
{
I = y 2;
mientras(I ltn) p>
{
if(s[x][I]= = z2){ can[2]= 1; romper;}
i;
}
}
if(s[x-1][y]= = z 1 amp; amp(x-1)>=0)
{
I = 0;
mientras(iltx)
{
if(s[I][y]= = z2){ can[3]= 1; ;}
i;
}
}
si(s[x 1][y]==z1) p>
{ I = x 2;
mientras(i ltn)
{
si(s[I][y]= = z2 ){ puede[4]= 1; romper;}
i;
}
}
if(s[x - 1][y 1]= = z 1 amp; amp(x-1)>=0)
{ I = 2;
mientras(y I lt; N amp amp (x-I gt;=0))
{ if(s[x-I][y I]= = z2){ can[5]= 1;break;}
i ;
}
}
if(s[x 1][y-1]= = z 1 amperio; amperio(y-1)>= 0 )
{ I = 2;
mientras(i ltN amp amp(y-I gt;=0))
{if(s[x i][ y-i ]==z2)
{ can[6]= 1; romper;}
i;
}
}< / p>
if(s[x-1][y-1]= = z 1 amp; amp(x-1)*(y-1)>=0)
{ I = 2;
mientras(x-I gt;= 0 amp ampy-I gt;=0)
{if(s[x-i][y-i]==z2)
{ puede[7]= 1;
Romper }
i
}
}
si(s[x 1][y 1]= = z 1)
{ I = 2;
mientras(I x lt; n)
{if(s[x i][y i]==z2)
{ can[8]= 1;
Romper;}
i ;
}
}
for(i=1,j=0;ilt=8;i)
si (puede [I]== 0)j;
if(j == 8 amp; ampQ==1)
{printf("¡Error! ");
Salir(1);}
si no(j!= 8)s[x][y]= z2;
if( puede[1]==1)
{ I = 1;
mientras(s[x][y-i]==z1)
{ s[ x][y-I]= z2;
i ;
}
can[1]= 0
}
si(puede[2]==1)
{ I = 1;
mientras(s[x]
[y i]==z1)
{ s[x][y I]= z2
i
}
; puede[2]= 0;
}
si(puede[3]==1)
{ I = 1;
mientras(s[x-i][y]==z1)
{ s[x-I][y]= z2;
i;
}
puede[3]= 0;
}
si(puede[4]==1)
{ I = 1;
mientras(s[x i][y]==z1)
{ s[x I][y]= z2;
i; p>
p>
}
puede[4]= 0;
}
si(puede[5]==1)
{ I = 1;
mientras(s[x-i][y i]==z1)
{ s[x-I][y I]= z2 ;
i;
}
puede[5]= 0;
}
si(puede [6]== 1)
{ I = 1;
mientras(s[x i][y-i]==z1)
{ s[x I][y-I] = z2;
i
}
can[6]=
}
si (puede[7]==1)
{ I = 1;
mientras(s[x-i][y-i]==z1)
{ s [x-I][y-I]= z2
i
}
can[7]= 0; p>} p>
if(can[8]==1)
{ I = 1;
mientras(s[x i][y i]== z1)
{ s[x I][y I]= z2
i
}
puede[8] = 0;
p>}
} /* snew */
void one()
{ int a, b; char g = ' o p>
cargar();
establecer color(15);
printf(" \ n \ n \ n \ n \ n \ n \ n \ n \ n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
printf("\ nPara salir del juego, presione la tecla "q".
\ n ");
print();
printf("Por favor, introduzca x (0 a 5): ");
while(1){
a = Obtener _ Ascii _ Key();
if(a == 113 | | a == 81){
printf("\nSalir ? (y o n)");
while(1)
{
if(Test _ Ascii _ Key(89) | | Test _ Ascii _ Key(121))
Salir(0);
si no(Test _ Ascii _ Key(110)| | Prueba _ Ascii _ Key(78))
{ printf(" \ n \ t¡Bienvenido de nuevo al juego! \ n ");
}}
if (a gt= 48 amp ampa lt; = 53){printf("\t¡Bien! x tiene get!\n ");
Pausa;}
}
a = a-48;
printf("Ingrese y (0 a 5): ";
while(1){
b = Obtener _ Ascii _ Key();
if(b == 113 | | b == 81)
{
printf("\n¿Salir? (Y o Y)");
mientras(1)
{
if(Prueba _ Ascii _ Clave(89)| | Prueba _ Ascii _ Clave(121))
Salir(0);
else if(Test _ Ascii _ Key(110)| | Prueba _ Ascii _ Key(78))
Pausa;
}}
If (b gt= 48 amp ampa lt=53){printf("\t¡Bien! ¡Tienes descanso!");
b = b-48;
q = 1;
nuevo(a, b, 'x', 'o');
q = 0;
guardar();
a = cal(gramo);
b = cal(' x '); p >
/* printf("\t\t\t\t\t\t\rA=d,B=d ",A,B);*/
}/* uno * /
Búsqueda no válida()
{
int i, j, r = 0
for(I = 0; i ltn; i )
for(j = 0; j ltn; j )
if(s[i][j]==HH)
r ;
if(r = = 0)fine = 0;
}
void two()
{ char h = ' xint fila[N*N], col[N * N];
int a=1, ii, j, t, t1, k[N * N];
cargar ();
for(ii = 0; ii ltn; ii )
for(j = 0; j ltn; j )<
/p>
if(s[ii][j]==HH)
{
Fila[a]= ii;
col[ a]= j;
a;
}
/*espacio derecho*/
for(ii = 1; ii lta ;ii)
{
cargar(); /*dos*/
snew(fila[ii], col[ii], ' o ', ' x ');
k[ii]= cal(h);
}
t = k[1];
ii-;
t 1 = ii;
Y (dos)
{
si(t lt;=k[ ii])
{ t = k[ii]; t 1 = ii;}
ii-;
}
a = t 1;
a = cal(' o ');
b = t
carga(); (fila[a], columna[a], ' o ', ' x ');
guardar()
borrar dispositivo(); printf("\n\n\t\t\t\t\tLa computadora está ubicada en: d, d ", fila [a], columna [a]).
}
main()
{ int i, j
int gd=DETECT, GM
<; p>clr SCR();init graph(amp;gd, ampgm, "d:\\TC\\bgi");
setbkcolor(negro);
tu();
sou();
setbkcolor(0);
for(I = 0;iltn;i)< / p>
for(j = 0; j ltn; j )
s[I][j]= ' 0 ';
s[2][2] = s[3][3]= ' x ';
s[2][3]= s[3][2]= ' o ';
guardar() ;
Cargando();
borrar dispositivo();
mientras(ok)
{
imprimir ();
uno();
dos();
buscar();
if(clave = = 113 | | clave == 81)
{
printf("\n¿Salir? (Y o Y)");
Y (!Test_Ascii_Key( 89) y amp! test_Ascii_Key(121));
break;
}
}
if (A gtB) outtextxy (400, 200) , "¡Tú ganas!");
else if (A lt; B) outtextxy (400, 200, "¡Yo gano!"); "¡Empate!");
printf("\nTú: dI: d ",A,B);
getch( );
} p>