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
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+3
View File
@@ -5,6 +5,9 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h> #include <SDL2/SDL_ttf.h>
extern unsigned int seed;
void screenDisplay (char **tab, int x, int y); void screenDisplay (char **tab, int x, int y);
int getMaxSize (dis display_user); int getMaxSize (dis display_user);
void displayImage (SDL_Renderer *renderer, SDL_Texture *texture, vect pos, void displayImage (SDL_Renderer *renderer, SDL_Texture *texture, vect pos,
-20
View File
@@ -1,20 +0,0 @@
####################
# #
# #
# #
# # #
# #
# # #
# I #
# P #
# #
# C #
# #
# # #
# #
# #
# #
# #
# #
# #
####################
-20
View File
@@ -1,20 +0,0 @@
####################
# #
# #
# #
# #
# #
# #
# I #
# #
# P #
# C #
# I #
# I #
# #
# #
# #
# #
# #
# #
####################
+14 -2
View File
@@ -84,10 +84,22 @@ void screenDisplayGameSDL (char **tab,vect dim_tab, dis *display_user, vect *pla
switch (tab[j][i]) switch (tab[j][i])
{ {
case EMPTY: 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; break;
case WALL: 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; break;
case PLAYER: case PLAYER:
img = IMG_Load ("image/player.png"); img = IMG_Load ("image/player.png");
+2
View File
@@ -522,6 +522,7 @@ int inEditorLoop (char **tab2d, vect *dim_tab, vect *playerPos, vect *targets,
if (event.type == SDL_MOUSEBUTTONDOWN) { if (event.type == SDL_MOUSEBUTTONDOWN) {
if (event.button.button == SDL_BUTTON_LEFT) { if (event.button.button == SDL_BUTTON_LEFT) {
// Lorsque le clic gauche est effectué // Lorsque le clic gauche est effectué
playAudio(2);
int click_x, click_y; int click_x, click_y;
SDL_GetMouseState(&click_x, &click_y); // Récupérer la position de la souris 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) { if (event.button.button == SDL_BUTTON_RIGHT) {
// Lorsque le clic gauche est effectué // Lorsque le clic gauche est effectué
playAudio(2);
int click_x, click_y; int click_x, click_y;
SDL_GetMouseState(&click_x, &click_y); // Récupérer la position de la souris SDL_GetMouseState(&click_x, &click_y); // Récupérer la position de la souris
+11 -2
View File
@@ -10,6 +10,7 @@
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
#include <SDL2/SDL_render.h> #include <SDL2/SDL_render.h>
#include <SDL2/SDL_mixer.h> #include <SDL2/SDL_mixer.h>
#include <time.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
@@ -17,6 +18,8 @@
#define SIZE_PLAY 20 #define SIZE_PLAY 20
#define SIZE_MENU 200 #define SIZE_MENU 200
// Définir une seed globale
unsigned int seed;
/** /**
@@ -28,7 +31,6 @@
*/ */
void playAudio(int sfx) void playAudio(int sfx)
{ {
// Charger un fichier son // Charger un fichier son
Mix_Chunk* sfx_win = Mix_LoadWAV("sfx/win.wav"); Mix_Chunk* sfx_win = Mix_LoadWAV("sfx/win.wav");
Mix_Chunk* sfx_lose = Mix_LoadWAV("sfx/lose.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_block_on_target = Mix_LoadWAV("sfx/blockontarget.wav");
Mix_Chunk* sfx_move = Mix_LoadWAV("sfx/move.mp3"); Mix_Chunk* sfx_move = Mix_LoadWAV("sfx/move.mp3");
Mix_Chunk* sfx_move_block = Mix_LoadWAV("sfx/moveblock.wav"); Mix_Chunk* sfx_move_block = Mix_LoadWAV("sfx/moveblock.wav");
switch (sfx) switch (sfx)
{ {
case 0: case 0:
@@ -60,9 +61,17 @@ void playAudio(int sfx)
} }
Mix_FreeChunk(sfx_win); 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 () int main ()
{ {
seed = (unsigned int)time(NULL);
dis display_user; dis display_user;
display_user.size_menu = SIZE_MENU; display_user.size_menu = SIZE_MENU;
display_user.size_box = SIZE_PLAY; display_user.size_box = SIZE_PLAY;