Commit 60f7648a authored by Nicolas LIENART's avatar Nicolas LIENART

SDL1 Sound fix

parent 6d429186
images/sprite-world/caillou.png

251 KB | W: | H:

images/sprite-world/caillou.png

237 KB | W: | H:

images/sprite-world/caillou.png
images/sprite-world/caillou.png
images/sprite-world/caillou.png
images/sprite-world/caillou.png
  • 2-up
  • Swipe
  • Onion skin
images/sprite_Button.png

17.2 KB | W: | H:

images/sprite_Button.png

14.6 KB | W: | H:

images/sprite_Button.png
images/sprite_Button.png
images/sprite_Button.png
images/sprite_Button.png
  • 2-up
  • Swipe
  • Onion skin
images/sprite_splash.png

27.9 KB | W: | H:

images/sprite_splash.png

25.6 KB | W: | H:

images/sprite_splash.png
images/sprite_splash.png
images/sprite_splash.png
images/sprite_splash.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/abeille.png

28.3 KB | W: | H:

images/tests/abeille.png

28.7 KB | W: | H:

images/tests/abeille.png
images/tests/abeille.png
images/tests/abeille.png
images/tests/abeille.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/add.png

7.97 KB | W: | H:

images/tests/add.png

7.37 KB | W: | H:

images/tests/add.png
images/tests/add.png
images/tests/add.png
images/tests/add.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/bizarre.png

39.6 KB | W: | H:

images/tests/bizarre.png

39.5 KB | W: | H:

images/tests/bizarre.png
images/tests/bizarre.png
images/tests/bizarre.png
images/tests/bizarre.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/coccinelle.png

12.6 KB | W: | H:

images/tests/coccinelle.png

13.7 KB | W: | H:

images/tests/coccinelle.png
images/tests/coccinelle.png
images/tests/coccinelle.png
images/tests/coccinelle.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/cookie.png

419 Bytes | W: | H:

images/tests/cookie.png

586 Bytes | W: | H:

images/tests/cookie.png
images/tests/cookie.png
images/tests/cookie.png
images/tests/cookie.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/delete.png

11 KB | W: | H:

images/tests/delete.png

12.1 KB | W: | H:

images/tests/delete.png
images/tests/delete.png
images/tests/delete.png
images/tests/delete.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/explosion.png

18.4 KB | W: | H:

images/tests/explosion.png

13.1 KB | W: | H:

images/tests/explosion.png
images/tests/explosion.png
images/tests/explosion.png
images/tests/explosion.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/food.png

50.9 KB | W: | H:

images/tests/food.png

50.7 KB | W: | H:

images/tests/food.png
images/tests/food.png
images/tests/food.png
images/tests/food.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/frites.png

51 KB | W: | H:

images/tests/frites.png

41.1 KB | W: | H:

images/tests/frites.png
images/tests/frites.png
images/tests/frites.png
images/tests/frites.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/gem1.png

17.9 KB | W: | H:

images/tests/gem1.png

15.7 KB | W: | H:

images/tests/gem1.png
images/tests/gem1.png
images/tests/gem1.png
images/tests/gem1.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/gem2.png

31.7 KB | W: | H:

images/tests/gem2.png

31.3 KB | W: | H:

images/tests/gem2.png
images/tests/gem2.png
images/tests/gem2.png
images/tests/gem2.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/gem3.png

21.2 KB | W: | H:

images/tests/gem3.png

21.2 KB | W: | H:

images/tests/gem3.png
images/tests/gem3.png
images/tests/gem3.png
images/tests/gem3.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/guepe.png

37.4 KB | W: | H:

images/tests/guepe.png

35.3 KB | W: | H:

images/tests/guepe.png
images/tests/guepe.png
images/tests/guepe.png
images/tests/guepe.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/hand.png

10.5 KB | W: | H:

images/tests/hand.png

11 KB | W: | H:

images/tests/hand.png
images/tests/hand.png
images/tests/hand.png
images/tests/hand.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/heart.png

2.04 KB | W: | H:

images/tests/heart.png

1.91 KB | W: | H:

images/tests/heart.png
images/tests/heart.png
images/tests/heart.png
images/tests/heart.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/info.png

14.8 KB | W: | H:

images/tests/info.png

15.3 KB | W: | H:

images/tests/info.png
images/tests/info.png
images/tests/info.png
images/tests/info.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/money.png

23.6 KB | W: | H:

images/tests/money.png

23.6 KB | W: | H:

images/tests/money.png
images/tests/money.png
images/tests/money.png
images/tests/money.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/munition.png

1.61 KB | W: | H:

images/tests/munition.png

10.7 KB | W: | H:

images/tests/munition.png
images/tests/munition.png
images/tests/munition.png
images/tests/munition.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/pause.png

13.4 KB | W: | H:

images/tests/pause.png

13.4 KB | W: | H:

images/tests/pause.png
images/tests/pause.png
images/tests/pause.png
images/tests/pause.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/plank.png

2.63 KB | W: | H:

images/tests/plank.png

2.66 KB | W: | H:

images/tests/plank.png
images/tests/plank.png
images/tests/plank.png
images/tests/plank.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/play.png

6.72 KB | W: | H:

images/tests/play.png

6.88 KB | W: | H:

images/tests/play.png
images/tests/play.png
images/tests/play.png
images/tests/play.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/plus.png

11.8 KB | W: | H:

images/tests/plus.png

11.8 KB | W: | H:

images/tests/plus.png
images/tests/plus.png
images/tests/plus.png
images/tests/plus.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/punaise.png

39.2 KB | W: | H:

images/tests/punaise.png

39.1 KB | W: | H:

images/tests/punaise.png
images/tests/punaise.png
images/tests/punaise.png
images/tests/punaise.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/sauterelle.png

11.2 KB | W: | H:

images/tests/sauterelle.png

12.1 KB | W: | H:

images/tests/sauterelle.png
images/tests/sauterelle.png
images/tests/sauterelle.png
images/tests/sauterelle.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/shield.png

4.4 KB | W: | H:

images/tests/shield.png

4.54 KB | W: | H:

images/tests/shield.png
images/tests/shield.png
images/tests/shield.png
images/tests/shield.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/speed.png

29.9 KB | W: | H:

images/tests/speed.png

29.7 KB | W: | H:

images/tests/speed.png
images/tests/speed.png
images/tests/speed.png
images/tests/speed.png
  • 2-up
  • Swipe
  • Onion skin
images/tests/target.png

12.6 KB | W: | H:

images/tests/target.png

12.6 KB | W: | H:

images/tests/target.png
images/tests/target.png
images/tests/target.png
images/tests/target.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -14,7 +14,6 @@ void sdlConfig_reshape(SDL_Surface** surface, unsigned int width, unsigned int h
SDL_Surface* surface_temp = SDL_SetVideoMode(width, height, 8, SDL_OPENGL);
SDL_ShowCursor(SDL_DISABLE);
if(NULL == surface_temp)
{
fprintf( stderr, "Erreur lors du redimensionnement de la fenetre.\n");
......
......@@ -52,9 +52,6 @@ int main(int argc, char *argv[])
gui_init();
sound_init();
// Position X, Y en pixel ET en indice de case de la souris
int pixelMouseX, pixelMouseY, caseMouseX, caseMouseY;
/* Boucle principale */
int loop = 1;
int frameFPS = 0;
......@@ -150,7 +147,7 @@ int main(int argc, char *argv[])
}
/* Liberation des ressources associees a la SDL */
SDL_FreeSurface(surface);
//SDL_FreeSurface(surface);
Mix_CloseAudio();
SDL_Quit();
return EXIT_SUCCESS;
......
......@@ -33,4 +33,5 @@ void itineraire_freeItiniraire(Itineraire* itineraire);
Chemin* itineraire_getChemin(Node* node_in, Node* node_out);
void itineraire_freeListChemins();
void itineraire_cleanListChemins();
int itineraire_checkValidChemin(Node* node_in, Node* node_out);
#endif //ITINERAIRE_H_
......@@ -42,7 +42,7 @@ void keyboard_handleKeypress(SDL_Event *event)
case 'x':
action = REMOVE;
break;
}
}
if (action != joueur->action) {
player_switchAction(action);
}
......@@ -50,30 +50,6 @@ void keyboard_handleKeypress(SDL_Event *event)
if (type != joueur->type) {
player_switchTowerType(type);
}
}
else if (gameData->gameState == MAINMENU) {
switch(key) {
case 'a':
itd_actionMenu(LEVEL1_BTN);
break;
case 'z':
itd_actionMenu(LEVEL2_BTN);
break;
case 'e':
itd_actionMenu(LEVEL3_BTN);
break;
}
} else if (gameData->gameState == LOSEMENU || gameData->gameState == WINMENU) {
switch(key) {
case 'a':
itd_actionMenu(MAINMENU_BTN);
break;
case 'z':
itd_actionMenu(REPLAY_BTN);
break;
}
}
}
}
......@@ -6,14 +6,14 @@ void sound_init()
printf("%s", Mix_GetError());
}
gameData->sound = malloc(sizeof(Mix_Chunk*)*16);
gameData->sound = malloc(sizeof(Mix_Chunk*)*20);
if (!gameData->sound) {
printf("ERROR ALLOC : sound");
exit(CHK_ERROR_ALLOC);
}
Mix_Music *musique;
musique = Mix_LoadMUS("sound/musique.wav");
musique = Mix_LoadMUS("sound/musique.mp3");
Mix_PlayMusic(musique, -1);
Mix_AllocateChannels(16);
......@@ -60,5 +60,4 @@ void sound_init()
son = Mix_LoadWAV("sound/error.wav");
gameData->sound[ERROR] = son;
}
......@@ -40,14 +40,13 @@ TextureName sprite_getTextureNameFromButtonName(ButtonName button_name)
Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
{
GLint internalFormat = GL_RGB;
GLint internalFormat = GL_RGBA;
GLenum format = GL_RGB;
if (strstr(image_path, ".png") != NULL) {
internalFormat = GL_RGBA;
//internalFormat = GL_BGRA;
format = GL_RGBA;
}
Texture* new_texture = malloc(sizeof(Texture));
if (!new_texture) {
printf("ERROR ALLOC : new_texture");
......@@ -58,6 +57,20 @@ Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
printf("IMG_Load: %s\n", IMG_GetError());
// handle error
}
GLenum texture_format;
GLint nOfColors = texture_surface->format->BytesPerPixel;
if( nOfColors == 4) {
if(texture_surface->format->Rmask == 0x000000ff)
texture_format = GL_RGBA;
else texture_format = GL_BGRA;
}
else if( nOfColors == 3 ) {
if(texture_surface->format->Rmask == 0x000000ff)
texture_format = GL_RGB;
else texture_format = GL_BGR;
}
new_texture->sprite_totalX = totalX;
new_texture->sprite_totalY = totalY;
......@@ -69,7 +82,8 @@ Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture_surface->w, texture_surface->h, 0, format, GL_UNSIGNED_BYTE, texture_surface->pixels);
glTexImage2D(GL_TEXTURE_2D, 0, nOfColors, texture_surface->w, texture_surface->h, 0, texture_format, GL_UNSIGNED_BYTE, texture_surface->pixels);
// NOTE: Unbinding
glBindTexture(GL_TEXTURE_2D, 0);
......@@ -79,7 +93,7 @@ Texture* sprite_importTexture(char image_path[], int totalX, int totalY)
void sprite_init()
{
gameData->textures = calloc(50, sizeof(Texture*));
gameData->textures = calloc(46, 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);
......@@ -137,7 +151,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];
gameData->textures[CENTRALE_TEX] = gameData->textures[FOOD_HIGH_TEX];
}
SpriteTexture* sprite_loadSprite(TextureName texture_name, int loop_duration, Bool loop)
......
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