37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
|
#include "graphics_utils.h"
|
||
|
#include <graph.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
void draw_grid(Game *game) {
|
||
|
EffacerEcran(CouleurParNom("white"));
|
||
|
int cell_size = 500 / game->size;
|
||
|
|
||
|
for (int i = 0; i <= game->size; i++) {
|
||
|
DessinerSegment(50 + i * cell_size, 50, 50 + i * cell_size, 50 + game->size * cell_size);
|
||
|
DessinerSegment(50, 50 + i * cell_size, 50 + game->size * cell_size, 50 + i * cell_size);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int choose_grid_size(int *mode) {
|
||
|
EffacerEcran(CouleurParNom("white"));
|
||
|
EcrireTexte(100, 100, "Choisissez une taille de grille (3 à 9)", 2);
|
||
|
EcrireTexte(100, 200, "Mode : 1 joueur (1) ou 2 joueurs (2)", 2);
|
||
|
|
||
|
int grid_size = 5;
|
||
|
|
||
|
while (!SourisCliquee());
|
||
|
SourisPosition();
|
||
|
|
||
|
grid_size = (_X - 50) / 100 + 3; // Ajustez selon votre interface
|
||
|
*mode = (_Y < 300) ? 1 : 2;
|
||
|
|
||
|
return grid_size;
|
||
|
}
|
||
|
|
||
|
void display_winner(int player) {
|
||
|
EffacerEcran(CouleurParNom("white"));
|
||
|
char msg[50];
|
||
|
sprintf(msg, "Le gagnant est le joueur %d!", player);
|
||
|
EcrireTexte(200, 250, msg, 2);
|
||
|
}
|