Exemple #1
0
/** @ingroup test
 *  @brief Teste les plateaux
 *
 */
void test_plateau(void)
{
	int taille = 19;
	Plateau plateau = creer_plateau(taille);
	assert(plateau_get_taille(plateau) == taille);

	for (int y = 0; y < taille; y++) {
		for (int x = 0; x < taille; x++) {
			Couleur c = rand() % 3;
			plateau_set(plateau, x, y, c);
			assert(plateau_get(plateau, x, y) == c);
		}
	}

	afficher_plateau(plateau);
	detruire_plateau(plateau);
}
int main(int argc, char ** argv)
{
	SimpleApplication::OnPreInitialize();

	timer1.Start();
	timer2.Start();

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); // | GLUT_STEREO
	glutInitWindowSize(1024, 768);
    glutCreateWindow("BiG Hour");

    glutDisplayFunc(draw);
    glutIdleFunc(idle);
    glutReshapeFunc(reshape);
    glutSpecialFunc(special);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    glutPassiveMotionFunc(motion);

	// Init GL
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);

	glEnable(GL_COLOR_MATERIAL);

	glEnable(GL_LIGHTING);
  	glEnable(GL_LIGHT0);

	glEnable(GL_NORMALIZE);

	creer_cube();
	creer_plateau();

	// Init Camera
	positionCamera();

	SimpleApplication::OnPostInitialize();

    glutMainLoop();

    return 0;
}
Exemple #3
0
/** @ingroup test
 *  @brief Teste les opérations d'accès aux cases du tableau
 */
void test_get_set(void)
{
	Plateau p = creer_plateau(9);

	const uint32_t * data = plateau_data(p);

	puts("debut");
	for (size_t i = 0; i < plateau_data_size(9) / sizeof(uint32_t); ++i)
		printf("%x\n", data[i]);
	puts("fin");

	plateau_set(p, 0, 1, BLANC);
	printf("%d %d\n", plateau_get(p, 0, 1), BLANC);

	puts("debut");
	data = plateau_data(p);
	for (size_t i = 0; i < plateau_data_size(9) / sizeof(uint32_t); ++i)
		printf("%x\n", data[i]);
	puts("fin");

	detruire_plateau(p);
}
Exemple #4
0
/** @ingroup test
 *  @brief Réponds aux questions posées
 *  @param Question à laquelle répondre
 *  @param partie de test
 *  @param inutilisé
 *  @return vrai
 */
bool test_reponses_aux_questions(enum Question question, Partie partie, void* userdata)
{
	(void) userdata;
	switch (question) {
		case TYPE_JOUEUR_BLANC:
			partie->joueurs[JOUEUR_BLANC].type = HUMAIN;
			return true;
		case NOM_JOUEUR_BLANC:
			strcpy(partie->joueurs[JOUEUR_BLANC].nom, "Blanc");
			return true;
		case TYPE_JOUEUR_NOIR:
			partie->joueurs[JOUEUR_NOIR].type = HUMAIN;
			return true;
		case NOM_JOUEUR_NOIR:
			strcpy(partie->joueurs[JOUEUR_NOIR].nom, "Noir");
			return true;
		case TAILLE_PLATEAU:
			partie->plateau = creer_plateau(9);
			return true;
		default:
			return true;
	}
}
Exemple #5
0
/** @ingroup test
 *  @brief Teste le bon fonctionnement de partie_jouer_coup().
 *
 */
void test_coup(void)
{
	Partie partie = creer_partie();
	partie->plateau = creer_plateau(9);
	partie->initialisee = true;
	partie->finie = false;

	// à tester sur valgrind
	partie->joueur_courant = JOUEUR_NOIR;
	s_Coup coup = {position(1, 0, 9)};
	(void) coup;
	assert(partie_jouer_coup(partie, coup));

	coup.position = POSITION_INVALIDE;
	assert(partie_jouer_coup(partie, coup));

	coup.position = position(0, 1, 9);
	assert(partie_jouer_coup(partie, coup));

	coup.position = position(0, 0, 9);
	assert(partie_jouer_coup(partie, coup) == false);

	detruire_partie(partie);
}
Exemple #6
0
SPlateau* init_plateau(int taille)
{
	Matrice* matrice = allouerMatrice(taille, taille);
	return creer_plateau(taille, matrice);
}