Commit 43998f42 authored by Nicolas LIENART's avatar Nicolas LIENART

Error sound and button fix

parent fd30ba54
......@@ -11,8 +11,8 @@ out 0 0 255
construct 0 0 0
inconstructible 255 0 234
# Player info
argent 2120
# Construction Data (DEGAT ALIM CAD PORTEE RANGE VAL VAL)
argent 3120
# Construction Data (DEGAT ALIM CAD PORTEE RANGE VAL VAL ENERGY)
laser 1 1 5 2 0 200 100 1
missile 2 1 2 1 0 300 150 2
radar 0 0 0 1 2 200 100
......
File added
......@@ -162,17 +162,3 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
......@@ -6,7 +6,7 @@ TypeCase* case_loadFromPPM()
unsigned char* pixel_data;
pixel_data = ppm_load();
TypeCase* cases = calloc(mapData->Xsplit*mapData->Ysplit, sizeof(int));
TypeCase* cases = calloc(mapData->Xsplit*mapData->Ysplit, sizeof(TypeCase));
RGBcolor* pixel_ppm = malloc(sizeof(RGBcolor));
if (!pixel_ppm) {
printf("ERROR ALLOC : mapData");
......@@ -393,10 +393,12 @@ void case_actionAdd(int caseX, int caseY)
printf("Porte monaie : %d \n", plateau->joueur->argent);
}
else {
Mix_PlayChannel(-1, gameData->sound[ERROR], 0);
printf("Vous n'avez pas assez\n");
}
}
else {
Mix_PlayChannel(-1, gameData->sound[ERROR], 0);
printf("This place is not available\n");
}
}
......@@ -411,6 +413,7 @@ void case_actionRemove(int caseX, int caseY)
printf("Porte monaie : %d \n", plateau->joueur->argent);
}
else {
Mix_PlayChannel(-1, gameData->sound[ERROR], 0);
printf("You can only remove your buildings\n");
}
}
......
......@@ -22,7 +22,7 @@ TextureText* display_loadTextureText(char text[])
TTF_CloseFont(font);
TTF_Quit();
TextureText* texture_texte = malloc(sizeof(TextureText));
TextureText* texture_texte = calloc(1, sizeof(TextureText));
if (!texture_texte) {
printf("ERROR ALLOC : mapData");
exit(EXIT_FAILURE);
......@@ -256,33 +256,33 @@ void display_initDefaultList()
GLuint idListInfos = glGenLists(1);
glNewList(idListInfos, GL_COMPILE);
glPushMatrix();
glPushMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].degats);
display_drawSingleStat(generalType, str, DAMAGE_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].degats);
display_drawSingleStat(generalType, str, DAMAGE_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].cadence);
display_drawSingleStat(generalType, str, CADENCE_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].cadence);
display_drawSingleStat(generalType, str, CADENCE_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].portee);
display_drawSingleStat(generalType, str, TARGET_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].portee);
display_drawSingleStat(generalType, str, TARGET_TEX, NULL);
position++;
glPopMatrix();
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].alimentation);
display_drawSingleStat(generalType, str, FOOD_TEX, NULL);
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%d", mapData->constructionData[i].alimentation);
display_drawSingleStat(generalType, str, FOOD_TEX, NULL);
position++;
glPopMatrix();
......@@ -631,7 +631,7 @@ void display_mapList(GLuint id)
sprite_displayFixedTexture(REINE_TEX);
break;
case INCONSTRUCTIBLE:
sprite_displayFixedTexture(REMOVE_TEX);
sprite_displayFixedTexture(CAILLOU_TEX);
break;
default:
sprite_displayFixedTexture(TERRAIN_1_TEX + rand()%5);
......@@ -806,6 +806,14 @@ void display_drawCaseHover(int index_case)
glColor4ub(255, 0, 0, 50);
}
}
if (plateau->joueur->action == REMOVE) {
if (case_getGeneralConstructionType(case_getType(caseX, caseY)) != OTHER) {
glColor4ub(255, 255, 255, 150);
}
else {
glColor4ub(255, 0, 0, 50);
}
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
......
......@@ -26,6 +26,7 @@
#include "sprite.h"
#include <time.h>
void display_drawCentrale(int index_case);
void display_levelTextCopy(char texte[], int button_id);
GLuint display_initDefaultListIcon(TextureName texture_name);
void display_printMoney();
......
......@@ -152,7 +152,7 @@ void mouse_handleClick()
Mix_PlayChannel(-1, gameData->sound[HITWOOD], 0);
mouse_handleButtonClick(gameData->button_hover);
}
else if (current_section->name == PLATEAU) {
else if (current_section->name == PLATEAU && gameData->gameState == LEVELPLAY) {
int casex, casey;
float casex_f, casey_f;
get_casesi(&casex, &casey, gameData->plateauGUI->dimensions);
......
......@@ -6,7 +6,7 @@ void sound_init()
printf("%s", Mix_GetError());
}
gameData->sound = malloc(sizeof(Mix_Music*)*13);
gameData->sound = malloc(sizeof(Mix_Chunk*)*16);
if (!gameData->sound) {
printf("ERROR ALLOC : sound");
exit(CHK_ERROR_ALLOC);
......@@ -16,7 +16,7 @@ void sound_init()
musique = Mix_LoadMUS("sound/musique.wav");
Mix_PlayMusic(musique, -1);
Mix_AllocateChannels(10);
Mix_AllocateChannels(16);
Mix_Chunk *son;
son = Mix_LoadWAV("sound/addTower.wav");
......@@ -58,4 +58,7 @@ void sound_init()
son = Mix_LoadWAV("sound/bleep.wav");
gameData->sound[BLEEP] = son;
son = Mix_LoadWAV("sound/error.wav");
gameData->sound[ERROR] = son;
}
......@@ -79,14 +79,13 @@ Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
void sprite_init()
{
gameData->textures = calloc(45, sizeof(Texture*));
gameData->textures = calloc(50, sizeof(Texture*));
gameData->textures[SOLDER_TEX] = sprite_importTexture("images/sprite-entities/cafard.png", 2, 1);
gameData->textures[HUGE_SOLDER_TEX] = sprite_importTexture("images/sprite-entities/punaise.png", 2, 1);
gameData->textures[BOSS_TEX] = sprite_importTexture("images/sprite-entities/gendarme.png", 2, 1);
gameData->textures[GERERAL_TEX] = sprite_importTexture("images/sprite-entities/larve.png", 2, 1);
gameData->textures[CENTRALE_TEX] = sprite_importTexture("images/tests/food.png", 1, 1);
gameData->textures[RADAR_TEX] = sprite_importTexture("images/tests/gem1.png", 1, 1);
gameData->textures[ARMEMENT_TEX] = sprite_importTexture("images/tests/gem2.png", 1, 1);
gameData->textures[MUNITION_TEX] = sprite_importTexture("images/tests/gem3.png", 1, 1);
......@@ -124,6 +123,8 @@ void sprite_init()
gameData->textures[CHEMIN_2_TEX] = sprite_importTexture("images/sprite-world/chemin2.png", 1, 1);
gameData->textures[CHEMIN_3_TEX] = sprite_importTexture("images/sprite-world/chemin3.png", 1, 1);
gameData->textures[CAILLOU_TEX] = sprite_importTexture("images/sprite-world/caillou.png", 1, 1);
gameData->textures[REINE_TEX] = sprite_importTexture("images/sprite-world/arrivee-reine.png", 1, 1);
gameData->textures[MAINMENU_TEX] = sprite_importTexture("images/sprite-gui/MainMenu.jpg", 1, 1);
......@@ -136,6 +137,7 @@ void sprite_init()
gameData->textures[FOOD_LOW_TEX] = sprite_importTexture("images/sprite-world/nourriture_low.png", 1, 1);
gameData->textures[FOOD_MEDIUM_TEX] = sprite_importTexture("images/sprite-world/nourriture_medium.png", 1, 1);
gameData->textures[FOOD_HIGH_TEX] = sprite_importTexture("images/sprite-world/nourriture_high.png", 1, 1);
gameData->textures[CENTRALE_TEX] =gameData->textures[FOOD_HIGH_TEX];
}
SpriteTexture* sprite_loadSprite(TextureName texture_name, int loop_duration, Bool loop)
......
......@@ -60,6 +60,7 @@ typedef enum Sound {
WINLEVEL,
SNAP,
HITWOOD,
ERROR,
BLEEP
} Sound;
......@@ -231,6 +232,7 @@ typedef enum TextureName {
FOOD_VERYLOW_TEX,
FOOD_MEDIUM_TEX,
FOOD_HIGH_TEX,
CAILLOU_TEX,
} TextureName;
typedef struct Texture {
......
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