diff --git a/library/Display/Display.c b/library/Display/Display.c index faa3d0db6d42438d07b05c3a2a0d962d727ea782..7b91b871aac5efbcebce3d9658f8ce79153c65b9 100644 --- a/library/Display/Display.c +++ b/library/Display/Display.c @@ -87,9 +87,9 @@ void refresh_graphics(SDL_Renderer *renderer, world_t *world,ressources_t *textu 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, 10, 10, 100, 33, "Jouer", textures->font, textures->color); - apply_text(renderer, 10, 10, 100, 33, "Magasin", textures->font, textures->color); - apply_text(renderer, 10, 10, 100, 33, "Exit", 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); diff --git a/library/Display/Display.o b/library/Display/Display.o index 0e46948a3d8e05ac496b156ce6185e4adec15441..e3960b9ae96f9a0d56604473d35592ad5773338f 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 dbbf35f8821d7383457551ccb82f10fbad46e21b..c7e932672c9addcd8829a65b25d22af166f9e854 100644 --- a/library/World/world.c +++ b/library/World/world.c @@ -19,10 +19,6 @@ void update_data(world_t *world){ allEvents(world); world->timer = SDL_GetTicks(); - }else{ - if (collidePoint(world->play, world->mouseX, world->mouseY)){ - world->isMenu = false; - } } } diff --git a/library/World/world.o b/library/World/world.o index ac91e73d5027e653c28f16359537079ab2194eb5..ac316bef20c84d1012518c74eae3fedbb3f4e98a 100644 Binary files a/library/World/world.o and b/library/World/world.o differ diff --git a/library/menu/menu.c b/library/menu/menu.c index 6fb361e7d3274fb59745002c43e36ea9cb578fff..361469b327de2e9e2750a38024a5986dbd82a91d 100644 --- a/library/menu/menu.c +++ b/library/menu/menu.c @@ -3,17 +3,17 @@ #include <stdio.h> #include <stdlib.h> + btn_t *init_btn(int x, int y, int w, int h){ btn_t *btn = malloc(sizeof(btn_t)); btn->rect.x = x; btn->rect.y = y; btn->rect.w = w; btn->rect.h = h; - return btn; } -int collidePoint(btn_t *btn, int x, int y){ - if (btn->rect.x > x && btn->rect.x + btn->rect.w < x && btn->rect.y > y && btn->rect.y + btn->rect.h < y;) return 1; - return 0; +bool collidePoint(btn_t *btn, int x, int y){ + if (btn->rect.x < x && btn->rect.x + btn->rect.w > x && btn->rect.y < y && btn->rect.y + btn->rect.h > y) return true; + return false; } \ No newline at end of file diff --git a/library/menu/menu.h b/library/menu/menu.h index 7857e54df020e28030ef26f24fdcb643734fac0e..c3c7a2629cb8359c06e4bfe52a13dce3786f30fb 100644 --- a/library/menu/menu.h +++ b/library/menu/menu.h @@ -5,17 +5,15 @@ #ifndef DEF_CONSTANTES #define DEF_CONSTANTES -#define LARGEUR_FENETRE 704 -#define HAUTEUR_FENETRE 704 - +#include <stdbool.h> struct btn{ SDL_Rect rect; -} +}; -typedef struct btn_t ; +typedef struct btn btn_t; btn_t *init_btn(int x, int y, int w, int h); -int collidePoint(btn_t *btn, int x, int y); +bool collidePoint(btn_t *btn, int x, int y); #endif \ No newline at end of file diff --git a/library/menu/menu.o b/library/menu/menu.o new file mode 100644 index 0000000000000000000000000000000000000000..84c315fce363b5059bff8e7a368ef00fceb3c935 Binary files /dev/null and b/library/menu/menu.o differ diff --git a/main.c b/main.c index 528cb883075f2b5d9f412a030f567113dd471382..7120aeb324cf6bd04ba3c9431eca3fb983018247 100644 --- a/main.c +++ b/main.c @@ -44,7 +44,7 @@ void handle_events(SDL_Event *event,world_t *world){ } //si une touche est appuyée - if(event->type == SDL_KEYDOWN){ + if(event->type == SDL_KEYDOWN){ //si la touche appuyée est 'D' if (!world->isMenu){ switch (event->key.keysym.sym){ @@ -63,8 +63,21 @@ void handle_events(SDL_Event *event,world_t *world){ break; } } + // print_sprite(world->vaisseau); } + if (event->type == SDL_MOUSEBUTTONDOWN){ + printf("aaa"); + if (world->isMenu){ + if (event->button.button == SDL_BUTTON_LEFT){ + printf("mouse(%d, %d) world rect (%d %d %d %d)\n", world->mouseX, world->mouseY, world->play->rect.x,world->play->rect.y,world->play->rect.w,world->play->rect.h ); + if (collidePoint(world->play, world->mouseX, world->mouseY)){ + printf("tesy"); + world->isMenu = false; + } + } + } + } } } diff --git a/main.o b/main.o index c75890bbd5318a30ae6f6f46094e66ade3cfd500..77b5469e25fa95b21b9e8a9d55ac728c51b01620 100644 Binary files a/main.o and b/main.o differ diff --git a/spacecorridor.exe b/spacecorridor.exe index 6209565d9c7e9d0c0ff7c946871c190418bf91db..ab0ec70ee0209b4ef6619c77b67a77086c0277f8 100644 Binary files a/spacecorridor.exe and b/spacecorridor.exe differ