-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.c
95 lines (76 loc) · 2 KB
/
menu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>
#include <stdlib.h>
#include "menu.h"
#define JOUER 1
#define REPRENDRE 2
#define QUITTER_MENU 3
int getInt()
{
int i;
int res = scanf("%d", &i);
if (res == 0)
while (fgetc(stdin) != '\n');// lire jusqu'au '\n', utilisé si l'utilisateur rentre une chaîne de caractères
return i;
}
int affichageMenu()
{
printf("---Menu---\n\n");
printf("1.Jouer\n");
printf("2.Reprendre\n");
printf("3.Quitter\n");
printf("\nVotre choix?\n\n");
return getInt();
}
int menu()
{
int choix = affichageMenu();
while(choix < JOUER || choix > QUITTER_MENU){
printf("Veuillez choisir parmi les options proposees\n");
choix = affichageMenu();
}
switch(choix)
{
case JOUER:
printf("Vous avez choisi de jouer\n");
break;
case REPRENDRE:
printf("Vous avez choisi de reprendre\n");
break;
case QUITTER_MENU:
printf("Vous avez choisi de quitter\n");
break;
}
return choix;
}
int affichageInteractionJoueur()
{
printf("--------Actions possibles---------\n\n");
printf("1.Reveler une case\n");
printf("2.Placer un drapeau\n");
printf("3.Supprimer un drapeau\n");
printf("4.Sauvegarder la partie actuelle\n");
printf("5.Quitter\n");
printf("\nVotre choix?\n\n");
return getInt();
}
void choisirCase(int* coordonnees, int taille)
{
int x,y;
printf("--------Choisir une case---------\n\n");
printf("-->Entrez x : ");
x = getInt();
while(x<1 || x>taille){
printf("Veuillez entrer une coordonnee existante\n");
printf("-->Entrez x : ");
x = getInt();
}
printf("-->Entrez y : ");
y = getInt();
while(y<1 || y>taille){
printf("Veuillez entrer une coordonnee existante\n");
printf("-->Entrez y : ");
y = getInt();
}
coordonnees[0] = x-1;
coordonnees[1] = y-1;
}