Jurk
24/03/2009, 23:45
Bueno, me estoy currando un remake de un juego (es un juego complejo en lo tajante a la logica, pero no en cuanto graficos...) y hay una p*ta estructura o funcion que me da por el p*to an*.
#include "cabeceras.h"
#include "constantes.h"
int x,y;
//estructuras
struct CardSet
{
int ID[NUMEROCARTAS];
char Nombre[NUMEROCARTAS][MAXNOMBRE];
int HP[NUMEROCARTAS];
int SP[NUMEROCARTAS];
int BackUp[NUMEROCARTAS][NUMEROMAXBACKUPS];
int Help[NUMEROCARTAS][NUMEROMAXHELPS];
char Rank[NUMEROCARTAS];
char SpecialAbility[NUMEROCARTAS];
};
//clases
class planos_tapete
{
public:
//funciones publicas
void inicializarTapete()
{
cout << endl;
for (y=0;y<2;y++)
{
for (x=0;x<3;x++)
{
CartaEnTapete[x][y]=0;
}
cout << endl;
}
}
void cogerYPonerCarta()
{
int CardID,jugador,posicion;
cout << " Introduce ID, jugador y posicion: ";
cin >> CardID >> jugador >> posicion;
ponerCarta (CardID, jugador, posicion);
}
void mostrarCartas()
{
for (y=0;y<2;y++)
{
for (x=0;x<3;x++)
{
cout << CartaEnTapete[x][y] << "\t";
}
cout << endl;
}
cout << endl;
}
void inicializarJugadores(int HP1, int HP2, int SP1, int SP2)
{
p1HP=HP1;
p2HP=HP2;
p1SP=SP1;
p2SP=SP2;
}
void mostrarGanador(int ganador)
{
cout << endl << "El ganador es el jugador " << ganador << endl << endl;
}
int checkHP()
{
int ganador;
ganador=0;
if (p1HP <=0) ganador =2;
if (p1HP <=0) ganador =1;
return ganador;
}
private:
//funciones privadas
void ponerCarta( int CardID, int jugador, int posicion)
{
CartaEnTapete[posicion][jugador]=CardID;
}
//varibles privadas de la clase
int CartaEnTapete[3][2];
int p1HP,p2HP,p1SP,p2SP;
};
//funciones
void cargarCartas()
{
for (x=0;x<NUMEROCARTAS;x++)
{
CardSet.ID[x]=x;
}
}
//main
int main()
{
int final=0;
cargarCartas();
planos_tapete tapete;
tapete.inicializarTapete();
tapete.inicializarJugadores(20,20,0,0);
tapete.mostrarCartas();
while (final==0)
{
tapete.cogerYPonerCarta();
tapete.mostrarCartas();
final=tapete.checkHP();
}
system("PAUSE");
return 0;
}
con las siguiente cabeceras... chapuceras...
#ifndef CABECERAS_H
#define CABECERAS_H
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
#endif
#ifndef CONSTANTES_H
#define CONSTANTES_H
#define CPU 1
#define PLAYER 1
#define NUMEROCARTAS 301
#define NUMEROMAXBACKUPS 10
#define NUMEROMAXHELPS 10
#define MAXNOMBRE 10
#define TRIANG 'A'
#define SQUARE 's'
#define ROUND 'o'
#endif
al intentar compilar todo esto me da un error garrulo:
1>d:\mis documentos\mi c++\fight\fight.cpp(99) : error C2143: error de sintaxis : falta ';' delante de '.'
1>d:\mis documentos\mi c++\fight\fight.cpp(99) : error C2143: error de sintaxis : falta ';' delante de '.'el error no aparece si no esta definida la funcion cargarCartas()...
una manita me hechais???
< - >
Ya lo he solucionado
Gililerdo que soy... al declarar la estructura hay que darle nombre, pero luego hay que dar nombre a la variable.... lerdosoy
asi queda infinitamente mejor:
struct Card
{
int ID;
char Nombre[MAXNOMBRE];
int HP;
int SP;
int BackUp[NUMEROMAXBACKUPS];
int Help[NUMEROMAXHELPS];
char Rank;
char SpecialAbility;
}CardSet[NUMEROCARTAS];
#include "cabeceras.h"
#include "constantes.h"
int x,y;
//estructuras
struct CardSet
{
int ID[NUMEROCARTAS];
char Nombre[NUMEROCARTAS][MAXNOMBRE];
int HP[NUMEROCARTAS];
int SP[NUMEROCARTAS];
int BackUp[NUMEROCARTAS][NUMEROMAXBACKUPS];
int Help[NUMEROCARTAS][NUMEROMAXHELPS];
char Rank[NUMEROCARTAS];
char SpecialAbility[NUMEROCARTAS];
};
//clases
class planos_tapete
{
public:
//funciones publicas
void inicializarTapete()
{
cout << endl;
for (y=0;y<2;y++)
{
for (x=0;x<3;x++)
{
CartaEnTapete[x][y]=0;
}
cout << endl;
}
}
void cogerYPonerCarta()
{
int CardID,jugador,posicion;
cout << " Introduce ID, jugador y posicion: ";
cin >> CardID >> jugador >> posicion;
ponerCarta (CardID, jugador, posicion);
}
void mostrarCartas()
{
for (y=0;y<2;y++)
{
for (x=0;x<3;x++)
{
cout << CartaEnTapete[x][y] << "\t";
}
cout << endl;
}
cout << endl;
}
void inicializarJugadores(int HP1, int HP2, int SP1, int SP2)
{
p1HP=HP1;
p2HP=HP2;
p1SP=SP1;
p2SP=SP2;
}
void mostrarGanador(int ganador)
{
cout << endl << "El ganador es el jugador " << ganador << endl << endl;
}
int checkHP()
{
int ganador;
ganador=0;
if (p1HP <=0) ganador =2;
if (p1HP <=0) ganador =1;
return ganador;
}
private:
//funciones privadas
void ponerCarta( int CardID, int jugador, int posicion)
{
CartaEnTapete[posicion][jugador]=CardID;
}
//varibles privadas de la clase
int CartaEnTapete[3][2];
int p1HP,p2HP,p1SP,p2SP;
};
//funciones
void cargarCartas()
{
for (x=0;x<NUMEROCARTAS;x++)
{
CardSet.ID[x]=x;
}
}
//main
int main()
{
int final=0;
cargarCartas();
planos_tapete tapete;
tapete.inicializarTapete();
tapete.inicializarJugadores(20,20,0,0);
tapete.mostrarCartas();
while (final==0)
{
tapete.cogerYPonerCarta();
tapete.mostrarCartas();
final=tapete.checkHP();
}
system("PAUSE");
return 0;
}
con las siguiente cabeceras... chapuceras...
#ifndef CABECERAS_H
#define CABECERAS_H
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
#endif
#ifndef CONSTANTES_H
#define CONSTANTES_H
#define CPU 1
#define PLAYER 1
#define NUMEROCARTAS 301
#define NUMEROMAXBACKUPS 10
#define NUMEROMAXHELPS 10
#define MAXNOMBRE 10
#define TRIANG 'A'
#define SQUARE 's'
#define ROUND 'o'
#endif
al intentar compilar todo esto me da un error garrulo:
1>d:\mis documentos\mi c++\fight\fight.cpp(99) : error C2143: error de sintaxis : falta ';' delante de '.'
1>d:\mis documentos\mi c++\fight\fight.cpp(99) : error C2143: error de sintaxis : falta ';' delante de '.'el error no aparece si no esta definida la funcion cargarCartas()...
una manita me hechais???
< - >
Ya lo he solucionado
Gililerdo que soy... al declarar la estructura hay que darle nombre, pero luego hay que dar nombre a la variable.... lerdosoy
asi queda infinitamente mejor:
struct Card
{
int ID;
char Nombre[MAXNOMBRE];
int HP;
int SP;
int BackUp[NUMEROMAXBACKUPS];
int Help[NUMEROMAXHELPS];
char Rank;
char SpecialAbility;
}CardSet[NUMEROCARTAS];