From 1ebdc12bff24b1f300b6032d78daa6f884c2f8f4 Mon Sep 17 00:00:00 2001 From: cyjullien1 Date: Wed, 8 Jan 2025 15:19:03 +0100 Subject: [PATCH] ui qui s'adapte --- image/BGColumn.png | 3 +++ image/background.png | 4 ++-- image/backgroundInEditor.png | 4 ++-- image/backgroundInGame.png | 4 ++-- image/backgroundTitlemenu.png | 4 ++-- include/display.h | 2 +- script/display.c | 34 ++++++++++++++++++++++++++++------ script/function.c | 3 ++- 8 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 image/BGColumn.png diff --git a/image/BGColumn.png b/image/BGColumn.png new file mode 100644 index 0000000..c52f401 --- /dev/null +++ b/image/BGColumn.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:089e79400775b28338bff387434c8acbde8662e5928fef842e052b9e2813d0d4 +size 5103 diff --git a/image/background.png b/image/background.png index 461a7ff..14828b9 100644 --- a/image/background.png +++ b/image/background.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:226f1898bfc4f6263c9d0d274bb021d6451d45861496feba11378b72a81dc6dc -size 5387 +oid sha256:344c437f12c6b13b81064f87926543126a92977f97e1b1d7482d470d452ce64d +size 5155 diff --git a/image/backgroundInEditor.png b/image/backgroundInEditor.png index 599e275..6774d77 100644 --- a/image/backgroundInEditor.png +++ b/image/backgroundInEditor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7a0fcf6a587c196bdfc69d2abcc978717d3f2772857d1747200ca2b6ca57cf0 -size 6043 +oid sha256:3e013d48e8a5321c4f52378abfb2b0fa094d693b7156c78f92f4fd14c32acd02 +size 5958 diff --git a/image/backgroundInGame.png b/image/backgroundInGame.png index 5c58040..cc99fdf 100644 --- a/image/backgroundInGame.png +++ b/image/backgroundInGame.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2c587e696368efee2f66f6529e1366a052f6cfc66e0d6c67912575840ae6496b -size 5449 +oid sha256:8412f96a6d0a9f220aadb8e7a91675a24dd2fa7c1f703c4d08cb4ba97e9e78a1 +size 5149 diff --git a/image/backgroundTitlemenu.png b/image/backgroundTitlemenu.png index 9374b56..067c0cc 100644 --- a/image/backgroundTitlemenu.png +++ b/image/backgroundTitlemenu.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59e426101a36eebceda56750b1116b29202d66001776176661e60fe86b737276 -size 5506 +oid sha256:12f81aeac9814e1694e3a46f8ccafa4dd08a2421ce76b6fabb4a330f5fce0e49 +size 5299 diff --git a/include/display.h b/include/display.h index 756ddb4..882161a 100644 --- a/include/display.h +++ b/include/display.h @@ -11,7 +11,7 @@ extern unsigned int seed; void screenDisplay (char **tab, int x, int y); int getMaxSize (dis display_user); void displayImage (SDL_Renderer *renderer, SDL_Texture *texture, vect pos, - int size); + vect size); void initSDL (dis *display_user); void displayTextSDL(dis *display_user,char *text, vect coor, vect size, int font_size); void screenDisplayGameSDL (char **tab,vect dim_tab, dis *display_user, vect *player_pos, int fov, vect direction); diff --git a/script/display.c b/script/display.c index effb710..decd13f 100644 --- a/script/display.c +++ b/script/display.c @@ -135,7 +135,8 @@ void screenDisplayGameSDL (char **tab,vect dim_tab, dis *display_user, vect *pla texture = SDL_CreateTextureFromSurface (display_user->renderer, img); - displayImage (display_user->renderer, texture, pos, size); + vect sizeV = {size, size}; + displayImage (display_user->renderer, texture, pos, sizeV); SDL_FreeSurface (img); SDL_DestroyTexture (texture); y++; @@ -211,9 +212,9 @@ void initSDL (dis *display_user) * \return Void **/ void displayImage (SDL_Renderer *renderer, SDL_Texture *texture, vect pos, - int size) + vect size) { - SDL_Rect rect = { pos.x, pos.y, size, size }; + SDL_Rect rect = { pos.x, pos.y, size.x, size.y }; SDL_RenderCopy (renderer, texture, NULL, &rect); } @@ -281,6 +282,15 @@ void backgroundDisplay(dis *display_user,int bg) SDL_Surface *img; SDL_Texture *texture; + unsigned int display_game + = display_user->size_window - display_user->size_menu; + int size = display_game / display_user->size_box; + unsigned int marge = display_user->size_menu / 2; + unsigned int i, j, x = 0, y = 0; + int start_i = 0, start_j = 0; + unsigned int limit_i = display_user->size_box, limit_j = display_user->size_box; + + img = IMG_Load("image/background.png"); if(bg==1) { @@ -292,14 +302,26 @@ void backgroundDisplay(dis *display_user,int bg) } else if(bg==3) { - img = IMG_Load("image/backgroundTitlemenu.png"); + img = IMG_Load("image/backgroundInGame.png"); } + texture = SDL_CreateTextureFromSurface (display_user->renderer, img); + + vect pos3 = {0,display_game}; + vect sizeV3 = {display_user->size_window , display_user->size_menu }; + displayImage(display_user->renderer, texture, pos3, sizeV3); + + img = IMG_Load("image/BGColumn.png"); texture = SDL_CreateTextureFromSurface (display_user->renderer, img); vect pos = {0, 0}; - displayImage(display_user->renderer, texture, pos, display_user->size_window); - + vect sizeV = {marge, display_game }; + displayImage(display_user->renderer, texture, pos, sizeV); + texture = SDL_CreateTextureFromSurface (display_user->renderer, img); + + vect pos2 = {display_game+marge, 0}; + vect sizeV2= {marge, display_game }; + displayImage(display_user->renderer, texture, pos2, sizeV2); SDL_RenderPresent (display_user->renderer); diff --git a/script/function.c b/script/function.c index 3ad119d..5f8ff8f 100644 --- a/script/function.c +++ b/script/function.c @@ -911,7 +911,8 @@ void winOrLoseLoop(dis *display_user,score *score_user, bool win) texture = SDL_CreateTextureFromSurface (display_user->renderer, img); vect pos = {0, 0}; - displayImage(display_user->renderer, texture, pos, display_user->size_window); + vect size = {display_user->size_window, display_user->size_window}; + displayImage(display_user->renderer, texture, pos, size); char text[50] = ""; snprintf(text, 50, "Score : %u",scoreCalculatorCyp(score_user, win));