Batalha
#pragma argsused
//---------------------------------------------------------------------------
#include
#include
#define DESTROYER 5
#define CARRIER 4
#define BOTE 3
#define TABULEIRO 1
//estruturas para o armazenamento das posições dos navios struct PosBote{ int Pos[2][2];
} pBOTE;
struct PosCarrier{ int Pos[3][2];
} pCARRIER;
struct PosDestroyer{ int Pos[4][2];
} pDESTROYER;
//variaveis de entrada das coordenadas int eLetra; int cLetra; int cNumero;
// variaveis para manipulacao da cena
GLint iRotateX = 0, iRotateY = 0, iRotateZ = 0, iZoom = 1;
//variaveis de estado do tabuleiro int Tab[10][10]; int dBote,dCarrier,dDestroyer; int aBote,aCarrier,aDestroyer;
//Função que inicializa arbitrariamente a posição dos navios void InicializaNavios(){ pBOTE.Pos[0][0]=7; pBOTE.Pos[0][1]=7; pBOTE.Pos[1][0]=7; pBOTE.Pos[1][1]=8; pCARRIER.Pos[0][0]=5; pCARRIER.Pos[0][1]=5; pCARRIER.Pos[1][0]=5; pCARRIER.Pos[1][1]=6; pCARRIER.Pos[2][0]=5; pCARRIER.Pos[2][1]=7; pDESTROYER.Pos[0][0]=2; pDESTROYER.Pos[0][1]=0; pDESTROYER.Pos[1][0]=2; pDESTROYER.Pos[1][1]=1; pDESTROYER.Pos[2][0]=2; pDESTROYER.Pos[2][1]=2; pDESTROYER.Pos[3][0]=2; pDESTROYER.Pos[3][1]=3;
};
void init(void)
{
int i,j; GLUquadricObj *q; glClearColor (0.0, 0.0, 0.0, 0.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glShadeModel (GL_SMOOTH); glMatrixMode(GL_MODELVIEW);
// Cria as display lists para os navios
//************************************* Destroyer ********************************* glNewList(DESTROYER, GL_COMPILE); q = gluNewQuadric();
glPushMatrix(); glScalef(2,1,2); glRotatef(45,0,1,0); glTranslatef(-7,0,0); glutWireCube(3); glPopMatrix();
glPushMatrix(); glScalef(2,1,2); glRotatef(-45,0,1,0); glTranslatef(7,0,0); glutWireCube(3); glPopMatrix();
glPushMatrix();