コード例 #1
0
ファイル: Castle.cpp プロジェクト: Narthe/CastleGenerator
void Castle::cleanMatrix()
{
	for (int i = 0; i < m_settings.matrix_width; i++)
		delete[] m_matrix[i];
	delete[] m_matrix;

	initMatrice();
}
コード例 #2
0
ファイル: main.c プロジェクト: Ousret/CrossWords-SDL
void generateGrille() {
	
	char msg[200];
	pthread_t thread_fillMatrice;
	
	memset(msg, 0, sizeof(msg));
	t_context * loading = SDL_newContext("CrossWords SDL", 0, 0, 800, 600);
	SDL_newImage(loading, NULL, "APP_BG_LOAD.png", 0, 0);
	SDL_newText(loading, NULL, msg, colorBlack, 50, 550);
	/* Init var for engine.c */
	nb_empty_cell = M*M;
	MAX_WORDS=0;
	memset(words, 0, sizeof(words));
	memset(id_matched, 0, sizeof(id_matched));
	
	// Matrice
	sprintf(msg, "Preparation de la table de mot-meles..");
	SDL_editText(loading, 0, msg, colorBlack, 50, 550);
	SDL_generate(loading);
	
	initMatrice();
	
	sprintf(msg, "Table preparee !");
	SDL_editText(loading, 0, msg, colorBlack, 50, 550);
	SDL_generate(loading);
	
	// Moteur
	sprintf(msg, "Generation d'une nouvelle grille, %i mot(s) sur %i places..", MAX_WORDS, limite_mots);
	SDL_editText(loading, 0, msg, colorBlack, 50, 550);
	SDL_generate(loading);
	
	if (pthread_create(&thread_fillMatrice, NULL, fillMatrice, NULL)) {
		perror("pthread_create");
		return;
    }
		
	while (MAX_WORDS < limite_mots) {
		
		sprintf(msg, "Generation d'une nouvelle grille, %i mot(s) sur %i places..", MAX_WORDS, limite_mots);
		SDL_editText(loading, 0, msg, colorBlack, 50, 550);
		SDL_generate(loading);
		
		SDL_Delay(100);
		
	}
	
	randomFilling();
	
	sprintf(msg, "Chargement..");
	SDL_editText(loading, 0, msg, colorBlack, 50, 550);
	SDL_generate(loading);
	
	SDL_freeContext(loading);
	
}
コード例 #3
0
ファイル: matrice.c プロジェクト: Haurustre/PP1-2014
/**
 * \fn Matrice chargerMatrice(char * path)
 * \brief Fonction qui charge une Matrice à partir des fichiers personnels
 * \param a une chaîne de caractère décrivant le chemin du fichier
 * \return une Matrice m.
 */
Matrice chargerMatrice(char * path){
  Matrice m;
  char var[1000];
  int * tailleMatrice = malloc(sizeof(int));
  int i;
  float *valIndiceMatrice = malloc(sizeof(float));

  //printf("Ouverture du fichier %s\n",path);
  FILE * tsp = fopen(path,"r");

  if(tsp == NULL){
    printf(" erreur %d\n",errno);
    if(errno == ENOENT)
      printf("Le fichier n'existe pas !\n");
    else
      printf("Erreur inconnue\n");
  }
  else{
    //printf("Creation de la matrice... ");
    fscanf(tsp,"%s",var);
    while(strcmp(var, "DIMENSION:") != 0 && !feof(tsp)){
      fscanf(tsp,"%s",var);
    }
    fscanf(tsp,"%d",tailleMatrice);
    m = initMatrice(*tailleMatrice);

    while(strcmp(var, "EDGE_WEIGHT_SECTION") != 0 && !feof(tsp)){
      fscanf(tsp,"%s",var);
    }
    if( ! feof(tsp)){
      for(i=0; i< ((*tailleMatrice) * (*tailleMatrice)); i++){
	fscanf(tsp,"%f",valIndiceMatrice);
	setIndMatrice(i,m,*valIndiceMatrice);
      }
    
    }
    else
      printf("Erreur lors de la lecture du fichier, DIMENSION doit etre specifie avant EDGE_WEIGHT_SECTION\n");
    fclose(tsp);
    //printf(" fait\n");
  }
  free(valIndiceMatrice);
  free(tailleMatrice);
  return m;
}
コード例 #4
0
ファイル: Castle.cpp プロジェクト: Narthe/CastleGenerator
Castle::Castle(SETTINGS s)
{
	m_settings = s;
	initMatrice();
}