Bonjour,
Voici le code source d'un petit jeu de plateau nommé Ataxx. C'est un jeux deux joueur, on peu jouer contre l'ordinateur (algo alpha-beta).
Version imprimable
Bonjour,
Voici le code source d'un petit jeu de plateau nommé Ataxx. C'est un jeux deux joueur, on peu jouer contre l'ordinateur (algo alpha-beta).
Ca fait un moment que je ne suis pas venu sur ce forum tiens... :oops: Ton jeu, c'est uniquement pour Linux ?
Eh... normalement j'ai utilisé des lib portable mais j'ai jamais essayé de le compiler sur Windows...
Ok, je testerais donc sous Windows ;)Citation:
Envoyé par Ekinoks
Bon je n'est pas réglé mon compilo au max mais juste avec -W -Wall et voici le log de compilation:
:aie: Nan pas taper:aie:Citation:
:: === Ataxx, Debug ===
D:\Programmation\TestsDvp\Ataxx\event.c:64: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:180: warning: implicit declaration of function `propagation_couleur_gtk'
D:\Programmation\TestsDvp\Ataxx\event.c:184: warning: passing arg 1 of `inverser_couleur' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:202: warning: implicit declaration of function `coup_auto'
D:\Programmation\TestsDvp\Ataxx\event.c:205: warning: implicit declaration of function `usleep'
D:\Programmation\TestsDvp\Ataxx\event.c:221: warning: implicit declaration of function `strcpy'
D:\Programmation\TestsDvp\Ataxx\event.c:263: warning: implicit declaration of function `executeActionNom'
D:\Programmation\TestsDvp\Ataxx\event.c:313: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:323: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:386: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:395: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:404: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:415: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:426: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:439: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:492: warning: passing arg 1 of `popup' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:514: warning: passing arg 1 of `gtk_widget_destroy' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:518: warning: passing arg 1 of `popup' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:477: warning: unused parameter 'w'
D:\Programmation\TestsDvp\Ataxx\event.c:533: warning: assignment from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:524: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:557: warning: passing arg 1 of `popup' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:563: warning: passing arg 2 of `sauver_fichier' discards qualifiers from pointer target type
D:\Programmation\TestsDvp\Ataxx\event.c:564: warning: passing arg 1 of `gtk_widget_destroy' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:546: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:579: warning: assignment from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:568: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\event.c:609: warning: passing arg 1 of `popup' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:638: warning: passing arg 1 of `gtk_widget_destroy' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:642: warning: passing arg 1 of `popup' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:594: warning: unused parameter 'w'
D:\Programmation\TestsDvp\Ataxx\event.c:657: warning: assignment from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\event.c:648: warning: unused parameter 'p_widget'
D:\Programmation\TestsDvp\Ataxx\fichier.c:38: warning: array subscript has type `char'
D:\Programmation\TestsDvp\Ataxx\fichier.c:40: warning: array subscript has type `char'
D:\Programmation\TestsDvp\Ataxx\fichier.c:164: warning: unused variable `choix'
D:\Programmation\TestsDvp\Ataxx\fichier.c:183: warning: unused variable `choix'
D:\Programmation\TestsDvp\Ataxx\fichier.c:184: warning: unused variable `cmd'
D:\Programmation\TestsDvp\Ataxx\fichier.c:320: warning: implicit declaration of function `propagation_couleur'
D:\Programmation\TestsDvp\Ataxx\fichier.c:321: warning: implicit declaration of function `inverser_couleur'
D:\Programmation\TestsDvp\Ataxx\fichier.c:328: warning: control reaches end of non-void function
D:\Programmation\TestsDvp\Ataxx\fichier.c:339: warning: implicit declaration of function `replay_init_plateau'
D:\Programmation\TestsDvp\Ataxx\fonction_gtk.c:35: warning: control reaches end of non-void function
D:\Programmation\TestsDvp\Ataxx\fonction_gtk.c:46: warning: control reaches end of non-void function
D:\Programmation\TestsDvp\Ataxx\fonction_gtk.c:67: warning: assignment from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\fonction_gtk.c:68: warning: assignment from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:45: warning: type defaults to `int' in declaration of `static_info_menu'
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:45: warning: initialization makes integer from pointer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:47: warning: assignment makes integer from pointer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:49: warning: return makes pointer from integer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:69: warning: assignment makes integer from pointer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:70: warning: assignment makes integer from pointer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:109: warning: implicit declaration of function `strcpy'
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:195: warning: passing arg 2 of pointer to function makes pointer from integer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:212: warning: passing arg 2 of pointer to function makes pointer from integer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:213: warning: passing arg 1 of `gtk_widget_destroy' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:231: warning: passing arg 2 of pointer to function makes pointer from integer without a cast
D:\Programmation\TestsDvp\Ataxx\menu_auto.c:264: warning: implicit declaration of function `strcmp'
D:\Programmation\TestsDvp\Ataxx\min_max.c:128: warning: implicit declaration of function `init_liste'
D:\Programmation\TestsDvp\Ataxx\min_max.c:142: warning: implicit declaration of function `coups_possibles_sans_equivalent'
D:\Programmation\TestsDvp\Ataxx\min_max.c:157: warning: implicit declaration of function `total_destroy_liste'
D:\Programmation\TestsDvp\Ataxx\primitives.c:64: warning: passing arg 4 of `box_image' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:64: warning: passing arg 5 of `box_image' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:126: warning: unused variable `action'
D:\Programmation\TestsDvp\Ataxx\primitives.c:159: warning: passing arg 1 of `gtk_label_set_text' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:163: warning: passing arg 1 of `gtk_label_set_text' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:167: warning: passing arg 1 of `gtk_label_set_text' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:171: warning: passing arg 1 of `gtk_label_set_text' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:175: warning: passing arg 1 of `gtk_label_set_text' from incompatible pointer type
D:\Programmation\TestsDvp\Ataxx\primitives.c:187: warning: unused variable `result'
D:\Programmation\TestsDvp\Ataxx\primitives_coups.c:134: warning: implicit declaration of function `inserer_dans_liste'
D:\Programmation\TestsDvp\Ataxx\primitives_sauts.c:95: warning: unused parameter 'pl'
D:\Programmation\TestsDvp\Ataxx\primitives_sauts.c:95: warning: unused parameter 'p'
D:\Programmation\TestsDvp\Ataxx\principal.c:75: warning: implicit declaration of function `creeAction'
D:\Programmation\TestsDvp\Ataxx\principal.c:104: warning: implicit declaration of function `executeActionNom'
obj\Debug\event.o:event.c:(.text+0x70c):: undefined reference to `usleep'
obj\Debug\event.o:event.c:(.text+0xbf3):: undefined reference to `usleep'
:: === Build finished: 2 errors, 75 warnings ===
Pour la fonction usleep j'ai un doute quant à sont existence sur Windows, dommage si ce n'est que cette fonction qui poserais un problème de portage, je pense qu'on peut facilement la remplacer dans le pire des cas, à voir sinon pas grave, ce sera un programme Linux tout simplement ;)
Sinon bin il faudrait quand même résoudre ces warning, surtout si le code source complet est diffusé. Pour ma part je pourrais joindre à ton projet le projet Code::Blocks pour la compilation sur Windows si la portabilité du programme est arrangée ;)
Ha oui, c'est vrais qu'il y avait plain de warning lors de la compilation (j'avais pas cherché à les enlever à vrai dire :^/) j'esserais de les enlever ^^Citation:
Envoyé par Franck.H
En remplaçant le usleep par Sleep ça devrais fonctionner je pense...Citation:
Envoyé par Franck.H
Ok =)Citation:
Envoyé par Franck.H
Tu gagnerais énormément en lisibilité en utilisant l'héritage.
Comment faire une pause dans le programme ? ;)Citation:
Envoyé par Ekinoks
Oui avec des fonction de la GLib c'est encore mieux, je les oublie à chaque fois :mouarf:
Impossible d'utiliser l'héritage, le sujet nous oblige à utiliser du C et non pas du C++... :^/Citation:
Envoyé par gege2061
On peut utiliser les règles de la POO en C, cela permet de mieux structurer ton programme : http://c.developpez.com/cours/#tutos-cCitation:
Envoyé par Ekinoks
Regarde pour les tutos:
- Introduction à la programmation orientée objet en C
- Les règles de codage pour programmer orienté objet en C
C'est d'ailleurs une technique utilisée dans la structuration de GTK+
Sans oublier tes tuto :Citation:
Envoyé par Franck.H
Les premières minutes d'un projet sont plus pénibles parce que tu crées tous tes objets (beaucoup de copier/coller/remplacement) mais après c'est que du bonheur :P Pour te donner une idée, la majorité de mes fonctions callback ne prennent plus de paramètres, ou uniquement un pseudo-pointeur this (avec g_signal_connect_swapped, j'ai même plus d'arguments inutiles).
MDR !!! je savais pas qu'on pourait faire de la POO en C !
va valoir que je regarde ça de plus près ça a l'aire lolesque :D
Quant tu en aura goûté ce sera plus du pratique plus que du lolesque :lol:Citation:
Envoyé par Ekinoks
Bon mieux vaut tard que jamais mais j'ai compilé ton projet sur Linux et j'ai une série plus qu'importante de Warning en tous genres, il faudrait peut-être revoir ca de ton côté:
Autant essayer de partager un code qui ne génère pas autant de warnings :aie: Sinon dans l'ensemble ca m'a l'aire de fonctionner :DCode:
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 event.c: In function «event_click_plateau": event.c:180: attention : implicit declaration of function «propagation_couleur_gtk" event.c:184: attention : passing argument 1 of «inverser_couleur" from incompatible pointer type event.c:202: attention : implicit declaration of function «coup_auto" event.c:205: attention : implicit declaration of function «usleep" event.c:221: attention : implicit declaration of function «strcpy" event.c:221: attention : incompatible implicit declaration of built-in function «strcpy" event.c:227: attention : incompatible implicit declaration of built-in function «strcpy" event.c: In function «event_jouer": event.c:263: attention : implicit declaration of function «executeActionNom" event.c: In function «event_replay": event.c:486: attention : incompatible implicit declaration of built-in function «strcpy" event.c:492: attention : passing argument 1 of «popup" from incompatible pointer type event.c:514: attention : passing argument 1 of «gtk_widget_destroy" from incompatible pointer type event.c:518: attention : passing argument 1 of «popup" from incompatible pointer type event.c: In function «cb_replay": event.c:533: attention : assignment from incompatible pointer type event.c: In function «event_sauver": event.c:557: attention : passing argument 1 of «popup" from incompatible pointer type event.c:563: attention : passing argument 2 of «sauver_fichier" discards qualifiers from pointer target type event.c:564: attention : passing argument 1 of «gtk_widget_destroy" from incompatible pointer type event.c: In function «cb_sauver": event.c:579: attention : assignment from incompatible pointer type event.c: In function «event_charger": event.c:603: attention : incompatible implicit declaration of built-in function «strcpy" event.c:609: attention : passing argument 1 of «popup" from incompatible pointer type event.c:638: attention : passing argument 1 of «gtk_widget_destroy" from incompatible pointer type event.c:642: attention : passing argument 1 of «popup" from incompatible pointer type event.c: In function «cb_charger": event.c:657: attention : assignment from incompatible pointer type fichier.c: In function «accepte": fichier.c:38: attention : array subscript has type «char" fichier.c:40: attention : array subscript has type «char" fichier.c: In function «ouvrir_fichier_ecriture": fichier.c:164: attention : unused variable «choix" fichier.c: In function «ouvrir_fichier_lecture": fichier.c:184: attention : unused variable «cmd" fichier.c:183: attention : unused variable «choix" fichier.c: In function «coup_suivant": fichier.c:320: attention : implicit declaration of function «propagation_couleur" fichier.c:321: attention : implicit declaration of function «inverser_couleur" fichier.c: In function «coup_num": fichier.c:339: attention : implicit declaration of function «replay_init_plateau" fichier.c: In function «coup_suivant": fichier.c:328: attention : control reaches end of non-void function fonction_gtk.c: In function «remplace_image": fonction_gtk.c:46: attention : « return » manquant dans une fonction devant retourner une valeur fonction_gtk.c: In function «box_image": fonction_gtk.c:67: attention : assignment from incompatible pointer type fonction_gtk.c:68: attention : assignment from incompatible pointer type fonction_gtk.c: In function «question": fonction_gtk.c:35: attention : control reaches end of non-void function menu_auto.c: In function «acceseur_info_menu": menu_auto.c:45: attention : type defaults to «int" in declaration of «static_info_menu" menu_auto.c:45: attention : initialization makes integer from pointer without a cast menu_auto.c:47: attention : assignment makes integer from pointer without a cast menu_auto.c:49: attention : return makes pointer from integer without a cast menu_auto.c: In function «init_menu": menu_auto.c:69: attention : assignment makes integer from pointer without a cast menu_auto.c:70: attention : assignment makes integer from pointer without a cast menu_auto.c: In function «newAction": menu_auto.c:109: attention : implicit declaration of function «strcpy" menu_auto.c:109: attention : incompatible implicit declaration of built-in function «strcpy" menu_auto.c: In function «affiche_bouton": menu_auto.c:195: attention : passing argument 2 of «*((void (**)(struct GtkWidget *, struct Plateau *))((i) * 4u) + ppf)" makes pointer from integer without a cast menu_auto.c: In function «efface_bouton": menu_auto.c:212: attention : passing argument 2 of «(acceseur_info_menu(0u)->all_bouton + (struct stBouton *)((i) * 8u))->action->pSuprime" makes pointer from integer without a cast menu_auto.c:213: attention : passing argument 1 of «gtk_widget_destroy" from incompatible pointer type menu_auto.c: In function «event_action": menu_auto.c:231: attention : passing argument 2 of «action->pClick" makes pointer from integer without a cast menu_auto.c: In function «executeActionNom": menu_auto.c:264: attention : implicit declaration of function «strcmp" min_max.c: In function «alpha_beta": min_max.c:128: attention : implicit declaration of function «init_liste" min_max.c:142: attention : implicit declaration of function «coups_possibles_sans_equivalent" min_max.c:157: attention : implicit declaration of function «total_destroy_liste" primitives.c: In function «cree_plateau_gtk": primitives.c:64: attention : passing argument 4 of «box_image" from incompatible pointer type primitives.c:64: attention : passing argument 5 of «box_image" from incompatible pointer type primitives.c: In function «replay_init_plateau": primitives.c:126: attention : unused variable «action" primitives.c: In function «affiche_gagnant_label": primitives.c:159: attention : passing argument 1 of «gtk_label_set_text" from incompatible pointer type primitives.c:163: attention : passing argument 1 of «gtk_label_set_text" from incompatible pointer type primitives.c:167: attention : passing argument 1 of «gtk_label_set_text" from incompatible pointer type primitives.c:171: attention : passing argument 1 of «gtk_label_set_text" from incompatible pointer type primitives.c:175: attention : passing argument 1 of «gtk_label_set_text" from incompatible pointer type primitives.c: In function «gagnant2": primitives.c:187: attention : unused variable «result" primitives_coups.c: In function «execute_coup": primitives_coups.c:134: attention : implicit declaration of function «inserer_dans_liste" principal.c: In function «main": principal.c:75: attention : implicit declaration of function «creeAction" principal.c:104: attention : implicit declaration of function «executeActionNom"
Salut Franck.H,
Oui je sais j'ai plain de warning :'(
c'est a cause des warnings sur des #include mal plancé en debut de projet que j'ai pas réussi a résoudre... du coup apres j'ai plus fait gaf au warning et voila le résultat :'(
Mais bon, je vais essayer de réduire la liste c'est vrai que là c'est un peu abusif :p
Oui un chouilla :aie:Citation:
Envoyé par Ekinoks