Red de conocimiento informático - Conocimiento informático - Código C++ para un juego pequeño

Código C++ para un juego pequeño

/*Un juego de stickman, verifique personalmente la operación*/

/*Agregue el siguiente comando al compilar: -std=c++11, de lo contrario se producirá un error de compilación*

#include< cstdio>

#include

#include

#include

#include < thread>

#include

#include

usando el espacio de nombres std;

const carácter sin firmar CTRL_KEY = 0XE0;

carácter sin firmar constante IZQUIERDA = 0X4B;

carácter sin firmar constante DERECHA = 0X4D;

carácter sin firmar constante ABAJO = 0X50;

const unsigned char UP = 0X48;

int hombres2[2]={0,0};

int mujeres2[2]={10,10};

int Game();

void gotoxy( int x, int y ) //el cursor se mueve a la posición ( x,y)

{

HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);

COORD pos;

pos.X = x;

pos.

SetConsoleCursorPosition( handle,pos);

}

int clean( int mm, int nn )

{

gotoxy ( mm , nn ) ;

printf ( " " );

gotoxy ( mm,nn+1);

printf ( " " );

gotoxy ( mm,nn+2);

printf ( " " );

}

int men( int x, int y )

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN);

gotoxy( x, y

printf); (" O ");

gotoxy( x, y+1 );

printf("");

gotoxy( x, y +2 );

printf("I I");

}

int mujeres( int i, int j )

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);

gotoxy( i+1,j );

pri

ntf(" O");

gotoxy( i+1,j+1 );

printf("");

gotoxy( i,j+2 );

printf("/I I\");

}

int m=10, n=10;

int x=0;int y=0;

int TorF()

{

if ( x == m && y == n ) devuelve 1;

si no, devuelve 0;

}

int womenmove()

{

int turno;

int YNbreak=0;

while( YNbreak == 0 )

{

YNbreaak = TorF();

girar =rand()%3;

limpiar( m, n );

if( m < x ) m++;

else m--;

si( m == x )

{

si( n < y ) n++;

else n--;

}

si ( m < 0 ) m = 0;

si ( m >= 75 ) m = 75;

si ( n < 0 ) n = 0;

si ( n >= 22 ) n = 22;

mujeres( m,n );

p>

mujeres2[0] = m;

mujeres2[1]=n;

Dormir(100);

}

system ( "cls" );

gotoxy ( 28, 10 );

printf ( "¡¡¡Moriste!!!!\n" );

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED| FOREGROUND_BLUE);

sistema ("pausa");

salida(0);

return 0;

}

int menmove()

{

system("cls" );

while (1)

{

cambiar( getch())

{

caso ARRIBA: y--;romper ;

caso ABAJO:y++;romper;

caso IZQUIERDA:x--;romper;

caso DERECHA:x++;romper;

}

sistema( "cls" );

si ( x < 0 ) x = 0;

si ( x > 77 ) x = 77;

si ( y < 0 ) y = 0;

si ( y > ; 22 ) y = 22;

hombres( x, y ) ;

hombres2[0] = x;

<

p> men2[1] = y;

}

}

int Juego()

{

mujeres( 10, 10 );

hombres( 0, 0 );

int t = 0;

hilo qq( womenmove );

menmove();

qq.join();

devuelve 0;

}

int main()

{

system( "mode con cols=80 lineas=25" );

printf ( "Cuando comience el juego, presiona cualquier tecla para despertar tu villano sexual azul. Si la anciana roja te toca, estás muerto");

printf ("Las teclas de dirección controlan al villano/n");

system (. "pausa" );

sistema ( "cls" );

Juego();

devuelve 0;

. }

/* Deja un me gusta antes de quitártelo, ¡gracias! */