diff --git a/APL1.1/SAE11_2021/menu.c b/APL1.1/SAE11_2021/menu.c index d305612..d03ebdb 100644 --- a/APL1.1/SAE11_2021/menu.c +++ b/APL1.1/SAE11_2021/menu.c @@ -7,32 +7,39 @@ #include "graph_sup.h" void UpdateSelection(char* selection, int param) { + int MenuHeight = HEIGHT - 120, i; if (selection == "lines") { - int i; SetColor(0, 0, 0); for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH - 200, 75 + i * 70, 50, 50); //Lignes SetColor(255, 0, 0); - for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH - 200, 75 + (param-3) * 70, 50, 50); + DessinerRectangle(WIDTH - 200, 75 + (param-3) * 70, 50, 50); } else if (selection == "columns") { - int i; SetColor(0, 0, 0); - for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + i * 70, 50, 50); //Lignes + for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + i * 70, 50, 50); //Colonnes SetColor(255, 0, 0); - for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + (param-3) * 70, 50, 50); + DessinerRectangle(WIDTH/2 + 150, 75 + (param-3) * 70, 50, 50); + } else if (selection == "image"){ + SetColor(0, 0, 0); + for (i=0; i<3; i++) DessinerRectangle(0, MenuHeight/3 * i, WIDTH/2, MenuHeight/3); + SetColor(255,0,0); + DessinerRectangle(0, MenuHeight/3 * param, WIDTH/2, MenuHeight/3); } }; int DrawMenu() { ClearButtons(); + EffacerEcran(GetColor(255, 255, 255)); int MenuHeight = HEIGHT - 120; int Lines = 3, Columns = 3, i; + int X_image, Y_image; char filename[100]; - strcpy(filename, "./images/luna.png"); SetColor(0, 0, 0); char str[3]; + EcrireTexte(WIDTH/2 +120, 50 , "Colonnes", 2); + EcrireTexte(WIDTH - 220, 50 , "Lignes", 2); for (i = 0; i <= 5; i++) { AddButton(WIDTH/2 + 150, 75 + i * 70, 50, 50, 10 + i); //Colonnes AddButton(WIDTH - 200, 75 + i * 70, 50, 50, 20 + i); //Lignes @@ -42,16 +49,26 @@ int DrawMenu() { EcrireTexte(WIDTH - 175, 100 + i * 70, str, 2); } - DessinerRectangle(WIDTH/2 - 100, HEIGHT - 100, 200, 80); - AddButton(WIDTH/2 - 100, HEIGHT - 100, 200, 80, 1); + DessinerRectangle(WIDTH/4 *3 - 100, HEIGHT - 100, 200, 80); + AddButton(WIDTH/4 *3 - 100, HEIGHT - 100, 200, 80, 1); + EcrireTexte(WIDTH/4 *3 - 75 , HEIGHT - 50, "Start taquin", 2); + + DessinerRectangle(WIDTH/4 -100, HEIGHT - 100, 200, 80); + AddButton(WIDTH/4 - 100, HEIGHT -100, 200, 80, 2); + EcrireTexte(WIDTH/4 - 90, HEIGHT - 50, "Quitter menu", 2); UpdateSelection("lines", Lines); UpdateSelection("columns", Columns); SetColor(0, 0, 0); DessinerRectangle(0, 0, WIDTH/2, MenuHeight/3); + AddButton(0, 0, WIDTH/2, MenuHeight/3, 3); + DessinerRectangle(0, MenuHeight/3, WIDTH/2, MenuHeight/3); + AddButton(0, MenuHeight/3, WIDTH/2, MenuHeight/3, 4); + DessinerRectangle(0, MenuHeight/3 * 2, WIDTH/2, MenuHeight/3); + AddButton(0, MenuHeight/3 *2, WIDTH/2, MenuHeight/3, 5); DessinerSegment(WIDTH/2, 0, WIDTH/2, MenuHeight); DessinerRectangle(0, MenuHeight, WIDTH, HEIGHT - MenuHeight); @@ -67,15 +84,33 @@ int DrawMenu() { } else if (BT_ID >= 20 && BT_ID <= 25) { Lines = BT_ID - 17; UpdateSelection("lines", Lines); - } else { + } else if (BT_ID >= 3 && BT_ID <= 5){ + UpdateSelection("image", BT_ID - 3); + if (BT_ID == 3){ + X_image = 500; + Y_image = 445; + strcpy(filename, "./images/luna.png"); + } else if (BT_ID == 4){ + X_image = 300; + Y_image = 168; + strcpy(filename, "./images/zenitsu.jpg"); + } else if (BT_ID == 5){ + X_image = 400; + Y_image = 400; + strcpy(filename, "./images/banzai.png"); + } + } else { if (BT_ID == 1) { ClearButtons(); EffacerEcran(GetColor(255, 255, 255)); - CreateTaquin(filename, 500, 445, Lines, Columns); - } + CreateTaquin(filename, X_image, Y_image, Lines, Columns); + return 1; + } else if (BT_ID == 2) { + return 0; + } } } } } return 0; -} \ No newline at end of file +} diff --git a/APL1.1/SAE11_2021/taquin.c b/APL1.1/SAE11_2021/taquin.c index a00a025..74e7c56 100644 --- a/APL1.1/SAE11_2021/taquin.c +++ b/APL1.1/SAE11_2021/taquin.c @@ -84,6 +84,8 @@ int TaquinRenderLoop() { controller = 0; button_id = GetButton(_X, _Y); if (button_id >= 0) MovePiece(button_id, 1); + else if (button_id == -3) printf("RandomizeTaquin()"); + else if (button_id == -2) return 0; } if (ToucheEnAttente()) { @@ -193,16 +195,19 @@ void CreateTaquin(char * filename, int ImageWidth, int ImageHeight, int lines, i ChargerImage(Filename, 50, OffsetY, 0, 0, ImageX, ImageY); AddButton(75, HEIGHT - 100, 250, 60, -2); //Bouton Quitter - AddButton(WIDTH - 325, HEIGHT - 100, 250, 60, -3); //Bouton Sauvegarder ? + EcrireTexte(160, HEIGHT -60, "Menu", 2); + + AddButton(WIDTH - 325, HEIGHT - 100, 250, 60, -3); //Bouton rejouer + EcrireTexte(WIDTH - 300, HEIGHT - 60, "Recommencer", 2); SetColor(0, 0, 0); DessinerRectangle(75, HEIGHT - 100, 250, 60); DessinerRectangle(WIDTH - 325, HEIGHT - 100, 250, 60); - //RandomizeTaquin(); + RandomizeTaquin(); UpdateTaquin(); if (TaquinRenderLoop()) { ShowVictoryScreen(); } -} \ No newline at end of file +}