Commit 590dd4c7 authored by LibertAntoine's avatar LibertAntoine

Add listChemin on mapData

parent 6b896d6b
...@@ -64,8 +64,6 @@ void case_initPlateau() ...@@ -64,8 +64,6 @@ void case_initPlateau()
return EXIT_FAILURE; return EXIT_FAILURE;
} }
plateau->listChemins = itineraire_initListChemins();
plateau->monster_hover = NULL; plateau->monster_hover = NULL;
plateau->index_case_hover = -1; plateau->index_case_hover = -1;
plateau->play = TRUE; plateau->play = TRUE;
...@@ -395,12 +393,18 @@ void case_handleAction(int caseX, int caseY) ...@@ -395,12 +393,18 @@ void case_handleAction(int caseX, int caseY)
} }
} }
void case_cleanCases() {
free(mapData->cases);
mapData->cases = case_loadFromPPM();
}
void case_freePlateau() { void case_freePlateau() {
free(plateau->joueur); free(plateau->joueur);
tour_freeListTours(plateau->listTours); tour_freeListTours(plateau->listTours);
monster_freeListMonsters(plateau->listMonsters); monster_freeListMonsters(plateau->listMonsters);
projectile_freeListProjectiles(plateau->listProjectiles); projectile_freeListProjectiles(plateau->listProjectiles);
itineraire_freeListChemins(); itineraire_cleanListChemins();
case_cleanCases();
free(plateau); free(plateau);
} }
......
...@@ -45,5 +45,6 @@ void case_actionRemove(int caseX, int caseY); ...@@ -45,5 +45,6 @@ void case_actionRemove(int caseX, int caseY);
void case_actionInfo(int caseX, int caseY); void case_actionInfo(int caseX, int caseY);
void case_handleAction(int caseX, int caseY); void case_handleAction(int caseX, int caseY);
void case_freePlateau(); void case_freePlateau();
void case_cleanCases();
#endif //CASES_H_ #endif //CASES_H_
...@@ -18,7 +18,7 @@ ButtonName gui_getButtonNameFromAction(Action action) ...@@ -18,7 +18,7 @@ ButtonName gui_getButtonNameFromAction(Action action)
} }
ButtonName gui_getButtonNameFromTypeCase(TypeCase type) ButtonName gui_getButtonNameFromTypeCase(TypeCase type)
{ {;
ButtonName button_name; ButtonName button_name;
switch(type) { switch(type) {
case LASER: case LASER:
......
...@@ -630,6 +630,7 @@ void idt_load(char* itd_path) ...@@ -630,6 +630,7 @@ void idt_load(char* itd_path)
if (mapData->contentState == allFlags) { if (mapData->contentState == allFlags) {
printf("file is valid\n"); printf("file is valid\n");
mapData->cases = case_loadFromPPM(); mapData->cases = case_loadFromPPM();
mapData->listChemins = itineraire_initListChemins();
} }
} }
} }
...@@ -680,6 +681,7 @@ void itd_initLevel() ...@@ -680,6 +681,7 @@ void itd_initLevel()
void itd_freeMapData() { void itd_freeMapData() {
wave_freeListWaves(); wave_freeListWaves();
itineraire_freeListChemins();
free(mapData->infosNodes); free(mapData->infosNodes);
free(mapData); free(mapData);
} }
......
...@@ -118,7 +118,6 @@ int itineraire_initMonster(Monster* monster) ...@@ -118,7 +118,6 @@ int itineraire_initMonster(Monster* monster)
monster->itineraire = itineraire; monster->itineraire = itineraire;
} }
// TODO: checker l'ambiguité des return
void itineraire_addEtape(Itineraire* itineraire, Node* node) { void itineraire_addEtape(Itineraire* itineraire, Node* node) {
Etape* etape = malloc(sizeof(Etape)); Etape* etape = malloc(sizeof(Etape));
etape->node = node; etape->node = node;
...@@ -133,9 +132,6 @@ void itineraire_addEtape(Itineraire* itineraire, Node* node) { ...@@ -133,9 +132,6 @@ void itineraire_addEtape(Itineraire* itineraire, Node* node) {
} }
currentEtape->next = etape; currentEtape->next = etape;
return 0; return 0;
etape->next = itineraire->next;
itineraire->next = etape;
return 0;
} }
ListChemins* itineraire_initListChemins() ListChemins* itineraire_initListChemins()
...@@ -208,7 +204,7 @@ void itineraire_removeValueChemin(Monster* monster) { ...@@ -208,7 +204,7 @@ void itineraire_removeValueChemin(Monster* monster) {
} }
Chemin* itineraire_getChemin(Node* node_in, Node* node_out) { Chemin* itineraire_getChemin(Node* node_in, Node* node_out) {
Chemin* currentChemin = plateau->listChemins->next; Chemin* currentChemin = mapData->listChemins->next;
char exist = 0; char exist = 0;
while(currentChemin != NULL) { while(currentChemin != NULL) {
...@@ -224,9 +220,9 @@ Chemin* itineraire_getChemin(Node* node_in, Node* node_out) { ...@@ -224,9 +220,9 @@ Chemin* itineraire_getChemin(Node* node_in, Node* node_out) {
void itineraire_freeListChemins() { void itineraire_freeListChemins() {
Chemin* cheminFree; Chemin* cheminFree;
Chemin* currentChemin = NULL; Chemin* currentChemin = NULL;
if(plateau->listChemins->next != NULL) { if(mapData->listChemins->next != NULL) {
cheminFree = plateau->listChemins->next; cheminFree = mapData->listChemins->next;
currentChemin = plateau->listChemins->next->next; currentChemin = mapData->listChemins->next->next;
free(cheminFree); free(cheminFree);
} }
while(currentChemin != NULL) { while(currentChemin != NULL) {
...@@ -236,6 +232,14 @@ void itineraire_freeListChemins() { ...@@ -236,6 +232,14 @@ void itineraire_freeListChemins() {
} }
} }
void itineraire_cleanListChemins() {
Chemin* currentChemin = mapData->listChemins->next;
while(currentChemin != NULL) {
currentChemin->dead_monsters = 0;
currentChemin = currentChemin->next;
}
}
int itineraire_checkValidChemin(Node* node_in, Node* node_out) { int itineraire_checkValidChemin(Node* node_in, Node* node_out) {
int x1 = floor(node_in->x); int x1 = floor(node_in->x);
int y1 = floor(node_in->y); int y1 = floor(node_in->y);
......
...@@ -32,5 +32,5 @@ void itineraire_removeValueChemin(Monster* monster); ...@@ -32,5 +32,5 @@ void itineraire_removeValueChemin(Monster* monster);
void itineraire_freeItiniraire(Itineraire* itineraire); void itineraire_freeItiniraire(Itineraire* itineraire);
Chemin* itineraire_getChemin(Node* node_in, Node* node_out); Chemin* itineraire_getChemin(Node* node_in, Node* node_out);
void itineraire_freeListChemins(); void itineraire_freeListChemins();
void itineraire_cleanListChemins();
#endif //ITINERAIRE_H_ #endif //ITINERAIRE_H_
...@@ -131,8 +131,25 @@ void monster_attack(Projectile* projectile) ...@@ -131,8 +131,25 @@ void monster_attack(Projectile* projectile)
void monster_kill(Monster* monster) void monster_kill(Monster* monster)
{ {
Mix_PlayChannel(-1, sound[MONSTERKILL], 0); switch (monster->type)
{
case SOLDER:
Mix_PlayChannel(-1, sound[SOLD], 0);
break;
case HUGE_SOLDER:
Mix_PlayChannel(-1, sound[HSOLD], 0);
break;
case GERERAL:
Mix_PlayChannel(-1, sound[GENE], 0);
break;
case BOSS:
Mix_PlayChannel(-1, sound[BOS], 0);
break;
}
monster->status = DEAD; monster->status = DEAD;
free(monster->sprite_texture); free(monster->sprite_texture);
monster->sprite_texture = sprite_loadSprite(SPLASH_TEX, 0, FALSE); monster->sprite_texture = sprite_loadSprite(SPLASH_TEX, 0, FALSE);
......
...@@ -49,9 +49,13 @@ typedef enum TypeMonster { ...@@ -49,9 +49,13 @@ typedef enum TypeMonster {
typedef enum Sound { typedef enum Sound {
MUSIQUE, MUSIQUE,
TOWER, TOWER,
CENTRAL,
PROJECTILE, PROJECTILE,
MONSTERKILL,
BEGINLEVEL, BEGINLEVEL,
SOLD,
HSOLD,
GENE,
BOS,
LOSELEVEL, LOSELEVEL,
WINLEVEL WINLEVEL
} Sound; } Sound;
...@@ -121,6 +125,13 @@ typedef struct ConstructionData { ...@@ -121,6 +125,13 @@ typedef struct ConstructionData {
int valeur_revente; int valeur_revente;
} ConstructionData; } ConstructionData;
typedef struct Chemin {
Node* node_in;
Node* node_out;
int dead_monsters;
struct Chemin* next;
} Chemin;
typedef struct DataMonsters { typedef struct DataMonsters {
float PDV; float PDV;
float strength; float strength;
...@@ -128,6 +139,11 @@ typedef struct DataMonsters { ...@@ -128,6 +139,11 @@ typedef struct DataMonsters {
int value; int value;
} DataMonsters; } DataMonsters;
typedef struct ListChemins {
int nbChemin;
Chemin* next;
} ListChemins;
typedef struct MapData { typedef struct MapData {
int Xsplit; int Xsplit;
int Ysplit; int Ysplit;
...@@ -143,9 +159,10 @@ typedef struct MapData { ...@@ -143,9 +159,10 @@ typedef struct MapData {
ListWaves* listWaves; ListWaves* listWaves;
ConstructionData constructionData[6]; ConstructionData constructionData[6];
DataMonsters dataMonsters[4]; DataMonsters dataMonsters[4];
ListChemins* listChemins;
GLuint idGrid; GLuint idGrid;
GLuint idMap; GLuint idMap;
TypeCase *cases; TypeCase* cases;
} MapData; } MapData;
typedef enum GeneralType { typedef enum GeneralType {
...@@ -154,8 +171,6 @@ typedef enum GeneralType { ...@@ -154,8 +171,6 @@ typedef enum GeneralType {
OTHER OTHER
} GeneralType; } GeneralType;
typedef struct Monster Monster; typedef struct Monster Monster;
typedef enum Bool { typedef enum Bool {
...@@ -328,18 +343,6 @@ typedef struct ListMonsters { ...@@ -328,18 +343,6 @@ typedef struct ListMonsters {
Monster* firstMonster; Monster* firstMonster;
} ListMonsters; } ListMonsters;
typedef struct Chemin {
Node* node_in;
Node* node_out;
int dead_monsters;
struct Chemin* next;
} Chemin;
typedef struct ListChemins {
int nbChemin;
Chemin* next;
} ListChemins;
typedef struct Plateau { typedef struct Plateau {
Bool play; Bool play;
Etat* joueur; Etat* joueur;
...@@ -351,7 +354,6 @@ typedef struct Plateau { ...@@ -351,7 +354,6 @@ typedef struct Plateau {
ListTours* listTours; ListTours* listTours;
ListMonsters* listMonsters; ListMonsters* listMonsters;
ListProjectiles* listProjectiles; ListProjectiles* listProjectiles;
ListChemins* listChemins;
Wave currentWave; Wave currentWave;
Tour **tours; Tour **tours;
} Plateau; } Plateau;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment