flower seed

This commit is contained in:
cyjullien1
2025-01-07 19:20:22 +01:00
parent 2c39110885
commit 0c20e2ae20
13 changed files with 51 additions and 47 deletions

View File

@@ -72,7 +72,7 @@ void screenDisplayGameSDL (char **tab,vect dim_tab, dis *display_user, vect *pla
size = display_game / (fov*2);
}
SDL_Surface *img;
SDL_Texture *texture;
@@ -84,10 +84,22 @@ void screenDisplayGameSDL (char **tab,vect dim_tab, dis *display_user, vect *pla
switch (tab[j][i])
{
case EMPTY:
img = IMG_Load ("image/empty.png");
srand(seed+i*15+j*13);
int rand_int = rand() % 45;
if(rand_int==26){img = IMG_Load ("image/empty_grass.png");}
else if(rand_int==27){img = IMG_Load ("image/empty_mud.png");}
else if(rand_int==28){img = IMG_Load ("image/empty_mushroom.png");}
else if(rand_int==29){img = IMG_Load ("image/empty_mushroom2.png");}
else{img = IMG_Load ("image/empty.png");}
break;
case WALL:
img = IMG_Load ("image/wall.png");
srand(seed+i*15+j*13);
int rand_int = rand() % 30;
if(rand_int==26){img = IMG_Load ("image/wall3.png");}
else if(rand_int==29){img = IMG_Load ("image/wall2.png");}
else{img = IMG_Load ("image/wall.png");}
break;
case PLAYER:
img = IMG_Load ("image/player.png");

View File

@@ -522,6 +522,7 @@ int inEditorLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
if (event.type == SDL_MOUSEBUTTONDOWN) {
if (event.button.button == SDL_BUTTON_LEFT) {
// Lorsque le clic gauche est effectué
playAudio(2);
int click_x, click_y;
SDL_GetMouseState(&click_x, &click_y); // Récupérer la position de la souris
@@ -548,6 +549,7 @@ int inEditorLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
}
if (event.button.button == SDL_BUTTON_RIGHT) {
// Lorsque le clic gauche est effectué
playAudio(2);
int click_x, click_y;
SDL_GetMouseState(&click_x, &click_y); // Récupérer la position de la souris

View File

@@ -10,6 +10,7 @@
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_mixer.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
@@ -17,6 +18,8 @@
#define SIZE_PLAY 20
#define SIZE_MENU 200
// Définir une seed globale
unsigned int seed;
/**
@@ -28,7 +31,6 @@
*/
void playAudio(int sfx)
{
// Charger un fichier son
Mix_Chunk* sfx_win = Mix_LoadWAV("sfx/win.wav");
Mix_Chunk* sfx_lose = Mix_LoadWAV("sfx/lose.wav");
@@ -36,7 +38,6 @@ void playAudio(int sfx)
Mix_Chunk* sfx_block_on_target = Mix_LoadWAV("sfx/blockontarget.wav");
Mix_Chunk* sfx_move = Mix_LoadWAV("sfx/move.mp3");
Mix_Chunk* sfx_move_block = Mix_LoadWAV("sfx/moveblock.wav");
switch (sfx)
{
case 0:
@@ -60,9 +61,17 @@ void playAudio(int sfx)
}
Mix_FreeChunk(sfx_win);
Mix_FreeChunk(sfx_lose);
Mix_FreeChunk(sfx_cant_move);
Mix_FreeChunk(sfx_block_on_target);
Mix_FreeChunk(sfx_move);
Mix_FreeChunk(sfx_move_block);
}
int main ()
{
seed = (unsigned int)time(NULL);
dis display_user;
display_user.size_menu = SIZE_MENU;
display_user.size_box = SIZE_PLAY;