Commit fd30ba54 authored by Nicolas LIENART's avatar Nicolas LIENART

Adaptative texture for centrale

parent 33b68769
......@@ -724,7 +724,7 @@ void display_drawSingleTower(int caseX, int caseY, TypeCase type)
sprite_displayFixedTexture(RADAR_TEX);
break;
case CENTRALE:
sprite_displayFixedTexture(CENTRALE_TEX);
display_drawCentrale(index_case);
break;
}
}
......@@ -732,6 +732,26 @@ void display_drawSingleTower(int caseX, int caseY, TypeCase type)
glPopMatrix();
}
void display_drawCentrale(int index_case)
{
float energy_status = (float) plateau->energies[index_case] / mapData->constructionData[CENTRALE].energy;
TextureName texture_name;
if (energy_status >= 0.75) {
texture_name = FOOD_HIGH_TEX;
}
else if (energy_status >= 0.5) {
texture_name = FOOD_MEDIUM_TEX;
}
else if (energy_status >= 0.25) {
texture_name = FOOD_LOW_TEX;
}
else {
texture_name = FOOD_VERYLOW_TEX;
}
sprite_displayFixedTexture(texture_name);
}
void display_drawAllTargetRanges()
{
int total_cases = mapData->Xsplit * mapData->Ysplit;
......
......@@ -152,16 +152,14 @@ void mouse_handleClick()
Mix_PlayChannel(-1, gameData->sound[HITWOOD], 0);
mouse_handleButtonClick(gameData->button_hover);
}
if(gameData->gameState == LEVELPLAY) {
if (current_section->name == PLATEAU) {
int casex, casey;
float casex_f, casey_f;
get_casesi(&casex, &casey, gameData->plateauGUI->dimensions);
get_casesf(&casex_f, &casey_f, gameData->plateauGUI->dimensions);
printf("%d %d\n", casex, casey);
printf("%f %f\n", casex_f, casey_f);
case_handleAction(casex +1, casey +1);
}
else if (current_section->name == PLATEAU) {
int casex, casey;
float casex_f, casey_f;
get_casesi(&casex, &casey, gameData->plateauGUI->dimensions);
get_casesf(&casex_f, &casey_f, gameData->plateauGUI->dimensions);
printf("%d %d\n", casex, casey);
printf("%f %f\n", casex_f, casey_f);
case_handleAction(casex +1, casey +1);
}
}
......
......@@ -54,10 +54,10 @@ Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
exit(CHK_ERROR_ALLOC);
}
SDL_Surface* texture_surface = IMG_Load(image_path);
if(!texture_surface) {
if(!texture_surface) {
printf("IMG_Load: %s\n", IMG_GetError());
// handle error
}
}
new_texture->sprite_totalX = totalX;
new_texture->sprite_totalY = totalY;
......@@ -79,7 +79,7 @@ if(!texture_surface) {
void sprite_init()
{
gameData->textures = calloc(41, sizeof(Texture*));
gameData->textures = calloc(45, 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);
......@@ -131,6 +131,11 @@ void sprite_init()
gameData->textures[WINMENU_TEX] = sprite_importTexture("images/sprite-gui/WinMenu.jpg", 1, 1);
gameData->textures[WOODPLANKS_TEX] = sprite_importTexture("images/sprite-gui/wood_planks.jpg", 1, 1);
gameData->textures[FOOD_VERYLOW_TEX] = sprite_importTexture("images/sprite-world/nourriture_verylow.png", 1, 1);
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);
}
SpriteTexture* sprite_loadSprite(TextureName texture_name, int loop_duration, Bool loop)
......
......@@ -226,7 +226,11 @@ typedef enum TextureName {
MAINMENU_TEX,
LOSEMENU_TEX,
WINMENU_TEX,
WOODPLANKS_TEX
WOODPLANKS_TEX,
FOOD_LOW_TEX,
FOOD_VERYLOW_TEX,
FOOD_MEDIUM_TEX,
FOOD_HIGH_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