diff --git a/library/Display/Display.c b/library/Display/Display.c index 7b91b871aac5efbcebce3d9658f8ce79153c65b9..b4476b4c109b8af55ef852ae36a13cc074cfa415 100644 --- a/library/Display/Display.c +++ b/library/Display/Display.c @@ -5,6 +5,7 @@ void init_ressource(SDL_Renderer *renderer, ressources_t *textures){ textures->background = load_image( "ressources/Elements/background2.bmp",renderer); + textures->bmenu = load_image( "ressources/image-menu.bmp",renderer); textures->ship = load_image( "ressources/spaceship.bmp",renderer); textures->finishLine = load_image( "ressources/finish_line.bmp",renderer); @@ -72,10 +73,22 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,ressources_t *textu //on vide le renderer clear_renderer(renderer); - //application des textures dans le renderer - apply_background(renderer, textures->background, world); + - if (!world->isMenu){ + if (world->isMenu == 0){ + ingame(renderer,world,textures); + }else if(world -> isMenu==1){ + inmenu(renderer,world,textures); + } + + update_screen(renderer); + +} +void inmenu(SDL_Renderer *renderer, world_t *world,ressources_t *textures){ + apply_background(renderer, textures->bmenu, world); +} +void ingame(SDL_Renderer *renderer, world_t *world,ressources_t *textures){ + apply_background(renderer, textures->background, world);//application des textures dans le renderer apply_sprite(renderer, textures->ship, world->vaisseau, world); apply_sprite(renderer, textures->finishLine, world->ligneArriver, world); apply_walls(renderer, textures->meteorite, world, textures); @@ -85,15 +98,7 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,ressources_t *textu world->str = strcats(world->str, 3, "temps: ",int_to_str((int)world->timer/1000), "s"); } apply_text(renderer, 10, 10, 100, 33, world->str, textures->font, textures->color); - }else{ - apply_text(renderer, 10, 10, 100, 33, "Menu", textures->font, textures->color); - apply_text(renderer, 100, 100, 100, 33, "Jouer", textures->font, textures->color); - apply_text(renderer, 100, 200, 100, 33, "Magasin", textures->font, textures->color); - apply_text(renderer, 100, 300, 100, 33, "Exit", textures->font, textures->color); - } - - update_screen(renderer); - + } int timer_update_s(world_t *world){ diff --git a/library/Display/Display.h b/library/Display/Display.h index 5a651004932c4c296c821a7a6b51fa9f3e45d493..dff9deb9a4afcae81b945062841e32550f6347e2 100644 --- a/library/Display/Display.h +++ b/library/Display/Display.h @@ -24,6 +24,7 @@ * \brief La structure qui contient les textures du jeu * * \param background + * \param bmenu * \param ship * \param meteorite * \param finishLine @@ -33,6 +34,7 @@ */ struct ressources_s{ SDL_Texture* background; /*!< Texture liée à l'image du fond de l'écran. */ + SDL_Texture* bmenu;/*!< Texture liée à l'image du fond du menu. */ SDL_Texture* ship; /*!< Texture liée à l'image du vaisseau. */ SDL_Texture* meteorite; /*!< Texture liée à l'image du météorite. */ SDL_Texture* e_rotate; /*!< Texture liée à l'image de l'élément de rotation. */ @@ -126,4 +128,9 @@ void clean(SDL_Window *window, SDL_Renderer * renderer, ressources_t *textures, * \return int */ int timer_update_s(world_t *world); + +void ingame(SDL_Renderer *renderer, world_t *world,ressources_t *textures); + +void inmenu(SDL_Renderer *renderer, world_t *world,ressources_t *textures); + #endif \ No newline at end of file diff --git a/library/Display/Display.o b/library/Display/Display.o index 6856ce5308c3860634f9df7e7f037593bc8427d9..9b226f40de633a9cf10e3effc1e611b310319f67 100644 Binary files a/library/Display/Display.o and b/library/Display/Display.o differ diff --git a/library/World/world.c b/library/World/world.c index 1d6e8d2183fca78b83b8c4225e7990c89c4ca352..248a4fdde2f13d9b081b75c52074c2a3dafb4b8a 100644 --- a/library/World/world.c +++ b/library/World/world.c @@ -2,7 +2,7 @@ #include "../utility/utility.h" void update_data(world_t *world){ - if (!world->isMenu){ + if (world->isMenu==0){ world->ligneArriver->y += (int)world->speed_h; update_walls(world); if (isOverScreen(world->vaisseau)){ @@ -36,24 +36,25 @@ void init_data(world_t * world){ world->vaisseau = init_sprite(world->vaisseau, SCREEN_WIDTH/2 - SHIP_SIZE/2, SCREEN_HEIGHT - SHIP_SIZE, SHIP_SIZE, SHIP_SIZE, '0'); init_walls(world); world->ligneArriver = init_sprite(world->ligneArriver, 0, -world->nb_lines_murs*METEORITE_SIZE-30 , SCREEN_WIDTH, FINISH_LINE_HEIGHT, 'z'); - - world->play = init_btn(100,40, 80, 80); - world->exit = init_btn(100, 300, 80, 80); - world->magasin = init_btn(100, 150, 80, 80); - world->sound = init_btn(0, 0, 100, 100); - + InitMenu(world); print_sprite(world->vaisseau); world->startTimer = SDL_GetTicks(); world->timer = SDL_GetTicks(); world->str = malloc(sizeof(char)*100); world->angle = 0.0; world->isFlipping = 0; - world->isMenu = true; + world->isMenu = 1; world->mouseX = 0; world->mouseY = 0; } +void InitMenu(world_t * world){ + world->play = init_btn(203,129, 218, 97); + world->exit = init_btn(202,294, 218, 97); + world->magasin = init_btn(436, 217, 218, 97); + world->sound = init_btn(0, 0, 100, 100); +} void clean_data(world_t *world){ /* utile uniquement si vous avez fait de l'allocation dynamique (malloc); la fonction ici doit permettre de libérer la mémoire (free) */ diff --git a/library/World/world.h b/library/World/world.h index 368f0d09e82ca6fd2fc0ed10bbf75c22e31ab9a7..b5e364a224d0ec1049a48cc4a7a94ee83ad65f7c 100644 --- a/library/World/world.h +++ b/library/World/world.h @@ -54,7 +54,7 @@ struct world_s{ char * str; // String affichant le temps sur le jeu double angle; // Angle de rotation de la map int isFlipping; // Indique si l'on est en train de faire une rotation de l'écran et dans quelle sens (0 : non droite, 1 : vers la droite, -1 : vers la gauche, -2 : non gauche) - bool isMenu; + int isMenu; int mouseX; int mouseY; @@ -127,4 +127,6 @@ void update_walls(world_t *world); * \param world */ void allEvents(world_t *world); + +void InitMenu(world_t *world); #endif diff --git a/library/World/world.o b/library/World/world.o index 8fb2d42d69ba00185a5fd8de1eb1601f87f810e1..223692b0303653d56a81b57c4a53c878f08ecf16 100644 Binary files a/library/World/world.o and b/library/World/world.o differ diff --git a/main.o b/main.o index 455f53f6e984d5ff79726fa1982864a2e5ab184b..1297e3a4694d1456ac735299520d83446907d63f 100644 Binary files a/main.o and b/main.o differ diff --git a/ressources/image-menu.bmp b/ressources/image-menu.bmp new file mode 100644 index 0000000000000000000000000000000000000000..db626e1c1520533532334f327cad53924bb590f8 Binary files /dev/null and b/ressources/image-menu.bmp differ diff --git a/spacecorridor.exe b/spacecorridor.exe index fec879cfe5e7e1f93c276a42c66003c3791b7c7a..b50007bf515cdd9601205ffd3e3363a273fb8114 100644 Binary files a/spacecorridor.exe and b/spacecorridor.exe differ