Bonjour !
C'est encore moi et mon petit jeu memory !
Donc pour vous expliquez mon projet, je dois réaliser un jeu "mémory" qui se présente comme ceci :
-http://img4.hostingpics.net/pics/181692325.png
-http://img4.hostingpics.net/pics/730413Sanstitre.png
Et un petit soucis c'est que lorsque je clique sur next (dans la deuxieme image rien ne se passe) alors que j'aimerais passer au niveau suivant.
J'ai créer un tableau bidimensionnelle pour 18 niveaux et 7 images puis j'ai mis quelle image a quelle position.
Puis voici mon btnNext, qui me donne rien, j'ai du mal codé quelque chose mais je sais pas quoi, et je me suis dis aussi, vu que mes classes sont dans un Panel, si je veux obtenir un autre niveau je dois peut etre remove ma form?
Code : Sélectionner tout - Visualiser dans une fenêtre à part public static int[,] tabReponseTest = new int[18,7] { { -1, -1, 3, 1, -1, -1, -1 }, { -1, -1, 6, 3, -1, -1, -1 }, { -1,-1, 1, 3, -1, -1, -1 }, { -1, 1, 3, 6, -1, -1, -1 }, { -1, 3, 6, 1, -1, -1, -1 }, { -1, 6, 3, 1, -1, -1, -1 }, { -1, 6, 3, 2, 1, -1, -1 }, { -1, 6, 2, 1, 3, -1, -1 }, { -1, 2, 6, 3, 1, -1, -1 }, { -1, 1, 3, 5, 6, 2, -1 }, { -1, 6, 5, 2, 3, 1, -1 }, { -1, 2, 6, 3, 1, 5, -1 }, { -1, 5, 2, 6, 1, 4, 3 }, { -1, 5, 1, 3, 4, 6, 2 }, { -1, 3, 6, 2, 4, 1, 5 }, { 2, 6, 5, 1, 3, 7, 4 }, { 3, 5, 7, 4, 1, 2, 6 }, { 4, 2, 1, 3, 6, 5, 7 }};
Classe en question :
Je pense que le problème est principalement dans l'evenement "BtnNext".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 class Test : Pere { Timer timer1; Button btnNextLevel; int niveau; public Test(): base() { niveau = 0; memoriseImages(); } public void memoriseImages() { this.timer1 = new Timer(); this.timer1.Interval = 2000; this.timer1.Tick += new System.EventHandler(this.timer1_Tick); timer1.Start(); for (int i = 0; i < nbImages; i++) { if (tabReponseTest[niveau, i] != -1) tabPictureBoxHaut[i].Image = tabBmp[categorieChoisie, tabReponseTest[niveau, i]]; else tabPictureBoxHaut[i].Image = null; } } public void ActionImages() { this.btnNextLevel = new Button(); this.btnNextLevel.Location = new System.Drawing.Point(800, 200); this.btnNextLevel.Name = "btnNextLevel"; this.btnNextLevel.Size = new System.Drawing.Size(75, 23); this.btnNextLevel.TabIndex = 0; this.btnNextLevel.Text = "Next Level"; this.btnNextLevel.UseVisualStyleBackColor = true; this.btnNextLevel.Click += new System.EventHandler(this.btnNextLevel_Click); this.Controls.Add(btnNextLevel); timer1.Stop(); PictureBoxBas(); EncadrePictureBoxBas(); ActiverDragandDrop(); } private void timer1_Tick(object sender, EventArgs e) { ActionImages(); for (int i = 0; i < tabPictureBoxHaut.Length; i++) { tabPictureBoxHaut[i].Image = null; } } private void btnNextLevel_Click(object sender, EventArgs e) { bool verifieImage = false; for (int _i = 0; _i < nbImages; _i++) { if (tabPictureBoxHaut[_i].Image == tabBmp[categorieChoisie, tabReponseTest[niveau, _i]]) { for (int i = 0; i < nbImages; i++) { tabPictureBoxHaut[i].BackColor = Color.Transparent; } verifieImage = true; } else { for (int i = 0; i < nbImages; i++) { tabPictureBoxHaut[i].BackColor = Color.Red; btnNextLevel.Enabled = false; } } } if (verifieImage) { MessageBox.Show("Bien joué ! niveau suivant ->"); niveau++; } } } }
Partager