Commit a11b0058 authored by Ant Man's avatar Ant Man

Quit button

parent 3ca3127a
......@@ -116,6 +116,7 @@ void gui_init()
gameData->topGUI = gui_addChildren(HEADER, 0, 0, gameData->bodyGUI->dimensions->width, 40, gameData->bodyGUI, WOODPLANKS_TEX, TRUE);
gui_addButton(gameData->topGUI, 600, 20, 45, 45, PAUSE_BTN, CLICKED, 0, FALSE, 0);
gui_addButton(gameData->topGUI, 500, 20, 45, 45, QUIT_BTN, INACTIVE, 0, FALSE, 0);
gameData->plateauGUI = gui_addChildren(PLATEAU, 0, 40, gameData->bodyGUI->dimensions->width, 600, gameData->bodyGUI, 0, FALSE);
......
......@@ -738,7 +738,14 @@ void idt_load(char* itd_path)
void itd_actionMenu(Button* button)
{
if(gameData->gameState == MAINMENU) {
if (gameData->gameState == LEVELPLAY) {
if (button->name == QUIT_BTN) {
case_freePlateau();
Mix_PlayChannel(-1, gameData->sound[LOSELEVEL], 0);
gameData->gameState = LOSEMENU;
}
}
else if(gameData->gameState == MAINMENU) {
if (button->name == LEVEL_BTN) {
char pathToITD[20] = "level/";
char ITDfile[20];
......
......@@ -101,6 +101,9 @@ void mouse_handleButtonClick(Button *button)
case PAUSE_BTN:
plateau->play = (plateau->play == TRUE) ? FALSE : TRUE;
break;
case QUIT_BTN:
itd_actionMenu(button);
break;
case RADAR_BTN:
type = RADAR;
break;
......@@ -132,11 +135,11 @@ void mouse_handleButtonClick(Button *button)
break;
}
if (action != joueur->action) {
if (gameData->gameState == LEVELPLAY && action != joueur->action) {
player_switchAction(action);
}
if (type != joueur->type && mapData->constructionData[type].valeur_achat <= plateau->joueur->argent) {
if (gameData->gameState == LEVELPLAY && type != joueur->type && mapData->constructionData[type].valeur_achat <= plateau->joueur->argent) {
player_switchTowerType(type);
}
}
......
......@@ -34,6 +34,9 @@ TextureName sprite_getTextureNameFromButtonName(ButtonName button_name)
case PAUSE_BTN:
texture_name = PAUSE_TEX;
break;
case QUIT_BTN:
texture_name = REMOVE_TEX;
break;
}
return texture_name;
}
......
......@@ -370,6 +370,7 @@ typedef struct Div {
typedef enum ButtonName {
PAUSE_BTN,
QUIT_BTN,
LASER_BTN,
MISSILE_BTN,
CENTRALE_BTN,
......
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