From 26e27b3fe9587b1370e816f2ea4ae22a05a25ea8 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Wed, 26 Mar 2025 09:56:06 +0100 Subject: [PATCH] Updated house --- maison.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/maison.c b/maison.c index d95db06..61e7689 100644 --- a/maison.c +++ b/maison.c @@ -156,11 +156,23 @@ #include +int quit(void) +{ + MLV_free_window(); + return 0; +} + int main(int argc, char *argv[]) { /* Créé et affiche la fenêtre */ MLV_create_window("House Drawing", "House", 640, 480); + /* Dessine le ciel (rectangle bleu) */ + MLV_draw_filled_rectangle(0, 0, 640, 480, MLV_COLOR_SKY_BLUE); + + /* Dessine l'herbe (rectangle vert) */ + MLV_draw_filled_rectangle(0, 400, 640, 80, MLV_COLOR_GREEN); + /* Dessine le mur principal (carré rouge) */ MLV_draw_filled_rectangle(200, 200, 200, 200, MLV_COLOR_RED); @@ -178,17 +190,21 @@ int main(int argc, char *argv[]) /* Dessine le soleil (cercle jaune) */ MLV_draw_filled_circle(500, 100, 50, MLV_COLOR_YELLOW); - - /* Dessine l'herbe (rectangle vert) */ - MLV_draw_filled_rectangle(0, 400, 640, 80, MLV_COLOR_GREEN); + + /* Text: press ESC to quit */ + MLV_draw_text(10, 10, "Press ESC to quit", MLV_COLOR_BLACK); /* Met à jour l'affichage */ MLV_actualise_window(); + + /* Attend que l'utilisateur appuie sur la touche Échap pour quitter */ + MLV_Keyboard_button key; + do { + MLV_wait_keyboard(&key, NULL, NULL); + } while (key != MLV_KEYBOARD_ESCAPE); - /* Attend 10 secondes avant la fin du programme */ - MLV_wait_seconds(20); + /* Appelle la fonction quit pour fermer la fenêtre */ + quit(); - /* Fermer la fenêtre */ - MLV_free_window(); return 0; } \ No newline at end of file