Commit 590dd4c7 authored by LibertAntoine's avatar LibertAntoine

Add listChemin on mapData

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