Création d'une structure et d'une fonction pour faciliter la gestion des cartes
- Création d'une structure "card" contenant toutes les informations concernant une carte (position, dimensions, état) - Création d'une fonction create_card() permettant de faciliter les actions à faire lors de la création d'une carte
This commit is contained in:
parent
b6d33c1a73
commit
dfbd2dc7e1
14
src/game.c
14
src/game.c
@ -8,6 +8,17 @@
|
|||||||
#define GAME_MARGIN_TOP 35
|
#define GAME_MARGIN_TOP 35
|
||||||
#define GAME_MARGIN_BOTTOM 20
|
#define GAME_MARGIN_BOTTOM 20
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int x, y, L, H, displayed, found;
|
||||||
|
char *file;
|
||||||
|
} card;
|
||||||
|
|
||||||
|
card create_card(int x, int y, int L, int H, char *file) {
|
||||||
|
card carte = {x, y, L, H, 0, 0, file};
|
||||||
|
|
||||||
|
return carte;
|
||||||
|
}
|
||||||
|
|
||||||
void game(int colonnes, int lignes) {
|
void game(int colonnes, int lignes) {
|
||||||
EffacerEcran(CouleurParComposante(54, 57, 63));
|
EffacerEcran(CouleurParComposante(54, 57, 63));
|
||||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||||
@ -23,10 +34,11 @@ void game(int colonnes, int lignes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int case_margin = case_max_dimensions * 0.05;
|
unsigned int case_margin = case_max_dimensions * 0.05;
|
||||||
|
card cards[lignes][colonnes];
|
||||||
|
|
||||||
for (unsigned int l = 0; l < lignes; l += 1) {
|
for (unsigned int l = 0; l < lignes; l += 1) {
|
||||||
for (unsigned int c = 0; c < colonnes; c += 1) {
|
for (unsigned int c = 0; c < colonnes; c += 1) {
|
||||||
DessinerRectangle(GAME_MARGIN_RIGHT + (c * case_max_dimensions), GAME_MARGIN_TOP + (l * case_max_dimensions), case_max_dimensions - (2 * case_margin), case_max_dimensions - (2 * case_margin));
|
cards[l][c] = create_card(GAME_MARGIN_RIGHT + (c * case_max_dimensions), GAME_MARGIN_TOP + (l * case_max_dimensions), case_max_dimensions - (2 * case_margin), case_max_dimensions - (2 * case_margin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user