-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularisation des fonctions dans le main
- Loading branch information
Showing
4 changed files
with
75 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "CosmicYonder.h" | ||
#include "logger.h" | ||
#include "ui/ui.h" | ||
|
||
Partie * creerPartie() { | ||
/* Fonction servant à créer la sauvegarde de la partie en allouant les différents | ||
éléments nécessaires pour la restaurer*/ | ||
Partie * partie = NULL; | ||
partie = malloc(sizeof(Partie)); | ||
if(partie == NULL) { | ||
logMessage(CRITICAL, "erreur malloc partie"); | ||
exit(1); | ||
} | ||
partie->joueur = malloc(sizeof(Joueur)); | ||
if(partie->joueur == NULL) { | ||
logMessage(CRITICAL, "erreur malloc joueur"); | ||
exit(1); | ||
} | ||
partie->carte = malloc(MAX_SALLES * sizeof(Salle)); | ||
if(partie->carte == NULL) { | ||
logMessage(CRITICAL, "erreur malloc carte"); | ||
exit(1); | ||
} | ||
partie->salles_existantes = 0; //compteur de salles existantes | ||
partie->objets_speciaux_apparus = 0; //Compteur des objets à récupérer pour gagner apparus | ||
partie->portesNonOuvertes = 0;//Compte les portes non ouvertes sur la carte | ||
partie->nb_obj_inv = 0; | ||
partie->nb_obj_spe_inv = 0; | ||
partie->mvEnnemic = 0; | ||
return partie; | ||
} | ||
|
||
int condition_victoire(Partie* partie){ | ||
int compteur = 0; | ||
for(int i = 0;i<partie->nb_obj_inv + partie->nb_obj_spe_inv;i++){ | ||
if(partie->joueur->inventaire.obTab[i].id >= 11){ | ||
compteur += 1; | ||
} | ||
} | ||
if(compteur == 4){ | ||
return 0; | ||
} | ||
else{ | ||
return 1; | ||
} | ||
|
||
} | ||
|
||
void chronos(int* minuteur,int*decr_minuteur){ | ||
/*decr_ minuteur ajuste le minuteur pour | ||
qu'il retire bien 1 seconde par seconde en jeu en comptant les images par secondes*/ | ||
(*decr_minuteur)++; | ||
if((*decr_minuteur) >= IMAGES_PAR_SECONDE){ | ||
(*decr_minuteur) = 0; | ||
(*minuteur)--; | ||
} | ||
} |