elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Ayuda con juego en c++
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con juego en c++  (Leído 3,587 veces)
Abbaidd

Desconectado Desconectado

Mensajes: 13


Ver Perfil
Ayuda con juego en c++
« en: 15 Diciembre 2010, 00:55 am »

Hola amigos soy nuevo en el foro y me gustaria que me ayudaran con un juego del gato y el raton donde el gato se mueve 2 espacios y el raton un espacio y el juego termina cuando el gato "atrapa" al raton la verdad me he esta quebrando la cabeza con este codigo pero yo se que aqui hay expertos y talvez es sencillo para ellos 
aqui esta el codigo pero cuando lo compilo con el dev c++ me sale [linker error] undifined reference to movimientoraton()..



#include <iostream>
#include <cstdlib>

using std::cout;
 using std::cin;
 

 enum Direction { DOWN, RIGHT, UP, LEFT };
 const int X_START = 2, Y_START = 0;
 const int Z_START = 11,T_START =11;
 void laberintotransversal( char [][ 12 ], int, int, int,int,int );
 void imprimirlaberinto( const char[][ 12 ] );
 void movimientoraton(const char[][12],int,int,int*,int*,int);
 bool validarRaton(const char[][12],int,int,int,int,int);
 bool movimientogato( const char [][ 12 ], int, int ,int,int);

 int main()
 {
 char laberinto [ 12 ][ 12 ] =
 { {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'},
 {'#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#'},
 {'#', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#'},
 {'#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#'},
 {'#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '#'},
 {'#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#'},
 {'#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#'},
 {'#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#'},
 {'#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#'},
 {'#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#'},
 {'#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '-', '#'},
 {'#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'} };

 laberintotransversal( laberinto , X_START, Y_START,Z_START, T_START, RIGHT );
 
 return 0;
 }

 void laberintotransversal( char laberinto [][ 12 ], int xCoord, int yCoord,int zCoord,int tCoord, int direccion )
 {
 static bool flag = false;

 laberinto [ xCoord ][ yCoord ] = 'X';
 laberinto [zCoord][tCoord]='0';
 imprimirlaberinto( laberinto  );
 int *z=&zCoord;
 int *t=&tCoord;

 for ( int mover = direccion, conta = 0; conta < 4; ++conta,
 ++mover, mover %= 4 )
 switch( mover ) {
 case DOWN:
 if ( movimientogato( laberinto , xCoord + 1, yCoord,zCoord,tCoord ) ) {
 laberintotransversal( laberinto , xCoord + 1, yCoord,zCoord,tCoord , LEFT );
 
 movimientoraton(laberinto,xCoord,yCoord,z,t,direccion);

 return;
 }
 break;
 case RIGHT:
 if ( movimientogato( laberinto , xCoord, yCoord + 1,zCoord,yCoord ) ) {
laberintotransversal( laberinto , xCoord, yCoord + 1,zCoord,tCoord , DOWN );
 movimientoraton (laberinto,xCoord,yCoord,z,t,direccion);
 return;
 }
 break;
 case UP:
 if ( movimientogato( laberinto , xCoord - 1, yCoord,zCoord,yCoord ) ) {
 laberintotransversal( laberinto , xCoord - 1, yCoord,zCoord,tCoord , RIGHT );
  movimientoraton (laberinto,xCoord,yCoord,z,t,direccion);
   return;
 }
 break;
 case LEFT:
 if ( movimientogato( laberinto , xCoord, yCoord - 1 ,zCoord,yCoord) ) {
 laberintotransversal( laberinto , xCoord, yCoord - 1,zCoord,tCoord , UP );
  movimientoraton (laberinto,xCoord,yCoord,z,t,direccion);
 return;
 }
 break;
 }
  }

 bool movimientogato( const char laberinto [][ 12 ], int r, int c,int p, int q )
 {
 return ( r >= 0 && r <= 11 && c >= 0 && c <= 11 && laberinto [ r ][ c ] != '#' );
 }

 
 
 void movimientoraton(char laberinto[][12],int x,int y,int *z,int *t,int direccion){
      int n=*z;
      int m=*t;
 for ( int mover2 = direccion, conta = 0; conta < 4; ++conta,
 ++mover2, mover2 %= 4 )
 switch( mover2 ) {
 case DOWN:
 if ( validarRaton( laberinto , x, y,n+1,m,direccion) ) {
 laberintotransversal( laberinto , x, y,n+1,m,direccion);
 
 return;
 }
 break;
 case RIGHT:
 if ( validarRaton( laberinto , x, y,n,m+1,direccion) ) {
laberintotransversal( laberinto , x, y,n,m+1,direccion);
 return;
 }
 break;
 case UP:
 if ( validarRaton( laberinto , x, y,n-1,m,direccion) ) {
 laberintotransversal( laberinto , x, y,n-1,m,direccion );
 return;
 }
 break;
 case LEFT:
 if ( validarRaton( laberinto , x, y,n,-1,direccion ) ) {
 laberintotransversal( laberinto , x, y,n,m-1 ,direccion);
 return;
 }
break;}
}
 
 
 
bool validarRaton(const char laberinto[][12],int x,int y,int n,int m)
{return ( m >= 0 && n<= 11 && m >= 0 && m<= 11 && laberinto [ n][m] != '#' );
     }
 
 
 
 
 
 
 
 
 
 
 
 
 
 void imprimirlaberinto( const char laberinto [][ 12 ] )
 {
 for ( int w = 0; w < 12; ++w) {

 for ( int o = 0; 0 < 12; ++o )
 cout << laberinto [ w][ 0] << ' ';

 cout << '\n';
 }

 cout << "\nPresione Enter para ver la siguiente jugada\n";
 cin.get();
 }


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda con un juego
Juegos y Consolas
TheChivo 0 1,862 Último mensaje 7 Septiembre 2004, 09:53 am
por TheChivo
ayuda con juego de rol
Juegos y Consolas
f3d3cav 2 1,855 Último mensaje 9 Abril 2008, 23:18 pm
por Castiblanco
Ayuda con juego
Programación Visual Basic
kiwisucks 4 1,903 Último mensaje 21 Octubre 2008, 01:42 am
por kiwisucks
Ayuda con un juego
Juegos y Consolas
Sasori-kun 9 3,291 Último mensaje 1 Abril 2009, 12:46 pm
por Sasori-kun
Ayuda Juego
Juegos y Consolas
XxRekcahlExX 1 2,265 Último mensaje 11 Agosto 2010, 14:24 pm
por Ariath
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines