-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
70 lines (63 loc) · 1.61 KB
/
main.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
#include <gtk/gtk.h>
#include <stdlib.h>
#include <stdio.h>
#include "base.h"
static void destroy(GtkWidget* widget, gpointer data)
{
(void) widget;
struct s_env_game* game;
game = data;
free_all(game);
gtk_main_quit();
}
static void move(GtkWidget* widget, gpointer data)
{
struct s_env_game* game;
t_terrain* terrain_all;
t_terrain* terrain;
game = data;
terrain_all = game->terrain;
terrain = game->terrain;
while (terrain->button != widget)
terrain = terrain->next;
if (check_case(terrain_all, terrain, game->round))
{
if (game->round % 2 == 0)
{
gtk_label_set_text(GTK_LABEL(game->label), "AU BLANC DE JOUER");
game->round = game->round + 1;
}
else if (game->round % 2 == 1)
{
gtk_label_set_text(GTK_LABEL(game->label), "AU NOIR DE JOUER");
game->round = game->round + 1;
}
}
refresh_score(game);
}
int main(int argc, char** argv)
{
(void) argc;
(void) argv;
env_game game;
GdkColor color;
gtk_init(&argc, &argv);
if(init_game(&game))
return 0;
init_score(&game);
gdk_color_parse ("brown", &color);
gtk_window_set_position(GTK_WINDOW(game.window),GTK_WIN_POS_CENTER);
generate_all_button(game.button, &color);
g_signal_connect(game.window, "destroy", G_CALLBACK(destroy),&game);
while (game.i != 64)
{
g_signal_connect(game.button[game.i], "clicked", G_CALLBACK(move), &game);
assign_button_coord(game.button[game.i], game.terrain, game.i);
game.i = game.i + 1;
}
generated_platform(game.hbox,game.vbox,game.button);
gtk_container_add(GTK_CONTAINER(game.window), GTK_WIDGET(game.vbox));
gtk_widget_show_all(game.window);
gtk_main();
return (0);
}