Skip to content
Snippets Groups Projects
Commit c4665386 authored by antoinemeyer5's avatar antoinemeyer5
Browse files

merge des codes pour game of life parfait

parent 05c65655
Branches
No related tags found
No related merge requests found
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
20
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0
0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
\ No newline at end of file
No preview for this file type
...@@ -4,10 +4,18 @@ int running; ...@@ -4,10 +4,18 @@ int running;
int game_state; int game_state;
int main(){ int main(int argc, char** argv){
running = 1; running = 1;
game_state = MENU; game_state = MENU;
initMap();
if(argc == 3){
game_state = GAME;
chargeNiveauFichier(argv[2], map, atoi(argv[1]));
printf("3 arg\n");
}
MainLoop(); MainLoop();
} }
\ No newline at end of file
...@@ -63,3 +63,35 @@ long long int MapToBinary(int ** map) ...@@ -63,3 +63,35 @@ long long int MapToBinary(int ** map)
} }
return binary; return binary;
} }
void chargeNiveauFichier(char *nom_fichier, int ** monde, int nbrLigne){
FILE *fichier = NULL;
int valeur;
int ligne = -1;
int colonne = 0;
fichier = fopen(nom_fichier, "r");
if(fichier != NULL){
while(fscanf(fichier, "%d", &valeur) != EOF){
if(ligne == -1){
MAPSIZE = valeur;
if(MAPSIZE != nbrLigne){
printf("PROBLEME DE DIMENSION\n");
return;
}
ligne = 0;
}else{
map[ligne][colonne] = valeur;
colonne = colonne + 1;
if(colonne==MAPSIZE){
ligne = ligne + 1;
colonne = 0;
if(ligne==MAPSIZE){
break;
}
}
}
}
}
fclose(fichier);
}
\ No newline at end of file
...@@ -10,5 +10,6 @@ void printMap(); ...@@ -10,5 +10,6 @@ void printMap();
void initMap(); void initMap();
void writeMap(char* filename); void writeMap(char* filename);
long long int MapToBinary(int ** map); long long int MapToBinary(int ** map);
void chargeNiveauFichier(char *, int **, int);
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment