Bonjour,

Je dois faire une sorte de Candy Crush selon les directives suivantes :
  • Gérer les bonbons bonus (Lorsqu'un alingement de 4 bonbons se fait, un super bonbon apparaît alors, et si ce super bonbon est dans un futur alignement, alors la colonne ou bien ligne tout dépends si c'est un alignement vertical/horizontale sera effacée !)
  • Les alignements doivent être correctement détectés
  • Le score du joueur doit évoluer en fonction du nombre et du type de bonbons éliminés.
  • Le score doit être affiché pendant, ou à la fin de la partie (sachant que la fin de la partie est lorsqu'il n'y a plus d'alignement possible).


Il y a quelques fonctionnalités facultatives telles que:
  • Pouvoir sauvegarder une partie et la recharger
  • Retenir le meilleur score
  • Faire des niveaux ou bien mettre de la musique.


J'ai déjà bien avancé mais je suis bloqué. J'ai fait le code qui détecte s'il y a des alignements déjà existants mais il bogue un peu car lorsqu'il y a un alignement, il le détecte, l'enlève mais ensuite c'est un peu le bazar. J'ai essayé de faire une fonction qui détecte les alignements déjà existants lorsqu'on commence une nouvelle partie mais je n'y arrive pas...

Donc pour résumer je cherche à :

  • Corriger le problème des bonbons qui sont mis lorsqu'un alignement est trouvé (je ne sais pas trop comment l'expliquer...). Corriger!
  • La fonction qui détecte les alignements au tout début de la partie.
  • Comment faire pour calculer le score du joueur (mettre des points qui dépendent de la longueur de l'alignement ?).
  • Le fait de changer un bonbon avec un autre mais ne crée pas d'alignement donc les ré-échanger.


Voici mon code :
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import java.awt.Point;
 
public class candycrush
{
    static class Bonbon
    {
        int type; // de 1 a 6 (carre,ovale,larme,rond,hexagone,saucisse)
        int niveau; // 1 = normal ; 2 = bonus ; 3 = super bonus
    }
 
    static class Partie
    {
        Bonbon[][] jeu;
        int points;
    }
 
    static class Alignement
    {
        Point debut,fin;
    }
 
    static Partie creerpartie (int l, int h) // Creer une nouvelle partie 
    {
        Partie p = new Partie();
        p.jeu = new Bonbon[h][l];
        for (int i=0 ; i<h; i++)
        {
            for(int j=0 ; j<l ; j++)
            {
                p.jeu[i][j] = new Bonbon();
                p.jeu[i][j].type = ((int) (Math.random()*6))+1;
                p.jeu[i][j].niveau = ((int) (Math.random()*3))+1;
 
            }
        }
        return p;
    }
 
    static void affichage (Partie p, InterfaceCC toto, int h, int l) // Affiche les differents types de bonbons dans une fonction
    {
        for (int i=0 ; i<h; i++)
        {
            for(int j=0 ; j<l ; j++)
            {
                if(p.jeu[i][j].type == 1)
                    toto.dessinerCarre(i,j,0);
                if(p.jeu[i][j].type  == 2)
                    toto.dessinerOvale(i,j,0);
                if(p.jeu[i][j].type == 3)
                    toto.dessinerLarme(i,j,0);
                if(p.jeu[i][j].type == 4)
                    toto.dessinerRond(i,j,0);
                if(p.jeu[i][j].type == 5)
                    toto.dessinerHexagone(i,j,0);
                if(p.jeu[i][j].type == 6)
                    toto.dessinerSaucisse(i,j,0);
             }
        }
    }
 
    static Alignement Alignement1 (Partie p) // Fonction qui detecte les alignements en cours de partie
    {
        int k;
        for (int i=0 ; i<p.jeu.length; i++)
        {
            for(int j=0 ; j<p.jeu[i].length; j++)
            {
                k=1;
 
                while(i+k<p.jeu.length && p.jeu[i][j].type == p.jeu[i+k][j].type) // Tant que la case qui suit i est du meme type on continue (alignement horizontale)
                {
                    k = k+1; //
                }
 
                if(k>2) // Si k est superieur a  2 alors il y a un alignement
                {
                    Alignement a = new Alignement();
                    a.debut = new Point();
                    a.debut.x = i;
                    a.debut.y = j;
                    a.fin = new Point();
                    a.fin.x = i+k-1;
                    a.fin.y = j;
                    return a;                
                }
 
                k=1;
                while(j+k<p.jeu[i].length && p.jeu[i][j].type == p.jeu[i][j+k].type)
                {
                    k = k+1;
                }
 
                if(k>2)
                {
                    Alignement a = new Alignement();
                    a.debut = new Point();
                    a.debut.x = i;
                    a.debut.y = j;
                    a.fin = new Point();
                    a.fin.x = i;
                    a.fin.y = j+k-1;
                    return a;
                }
 
            }
        }
        return null;
    }
    static void DecalerBonbon (Partie p, Alignement a)
    {
        if(a.debut.y == a.fin.y) //Alignement horizontal
        {
            for(int i = a.debut.x ; i<= a.fin.x ; i++)
            {
                for(int j = a.debut.y ; j>=1 ; j--)
                {
 
                    p.jeu[i][j] = p.jeu[i][j-1];
 
 
                }
                p.jeu[i][0].type = ((int) (Math.random()*6))+1;
            }
        }
        if(a.debut.x == a.fin.x) // Alignement vertical
        {
 
            for(int j = 0 ; a.fin.y-j >= 0 ; j++)
            {
                if(a.debut.y-1-j >= 0)
                {
                    p.jeu[a.debut.x][a.fin.y-j] = p.jeu[a.debut.x][a.debut.y-1-j];
                }
                else
                {
                    p.jeu[a.debut.x][a.fin.y-j].type = ((int) (Math.random()*6))+1;
                }
            }
        }
 
    }
 
    public static void main(String[] args)
    {
        int l,h,min,max,temporaire;
        Point p1 = new Point();
        Point p2 = new Point();
        l = 8;
        h = 8;
        min = 1;
        max = 6;
        InterfaceCC toto = new InterfaceCC(h,l);
 
        Partie p = creerpartie(8,8);
 
        while (true) // On peut cliquer jusqu'a  ce qu'il n'est plus de combinaison possible
        {
            affichage(p,toto,h,l);
            p1 = toto.clicCase();    //Nouveau point afin d'inverser 2 bonbons
            System.out.println(p1.x + " " + p1.y); //Garde en memoire le p1
            p2 = toto.clicCase();
            System.out.println(p2.x + " " + p2.y);
            //inverse 2 points
            if((p1.x==p2.x && Math.abs(p1.y-p2.y)==1) || (p1.y==p2.y && Math.abs(p1.x-p2.x)==1)) //
            { 
                temporaire = p.jeu[p1.x][p1.y].type; 
                p.jeu[p1.x][p1.y].type = p.jeu[p2.x][p2.y].type;
                p.jeu[p2.x][p2.y].type = temporaire;
                affichage(p,toto,h,l);
                Alignement a = Alignement1(p);
                System.out.println(a.debut.x+","+a.debut.y+"   ->    "+a.fin.x+","+a.fin.y);
 
                DecalerBonbon(p,a);
            }
        }
    }
}
Et voici l'interface déjà donné :

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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.*;
import static javax.swing.SwingConstants.*;
 
public class InterfaceCC extends JFrame implements MouseListener{
 
    private interface GraphicEntity{
        public void paint(Graphics2D g, Point p, int cell, int border);
    }
 
    private class Carre implements GraphicEntity{
        Color c = Color.GREEN; int niveau;
        public Carre(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            float coeff = 8.0f;
            GeneralPath tour = new GeneralPath();
            tour.moveTo((p.x+1)*cell-border,p.y*cell+border);
            tour.curveTo((p.x+1)*cell-border,p.y*cell+border,(p.x+1)*cell-border-cell/coeff,p.y*cell+cell/2.0f,(p.x+1)*cell-border,(p.y+1)*cell-border);
            tour.lineTo(p.x*cell+border,(p.y+1)*cell-border);
            tour.curveTo(p.x*cell+border,(p.y+1)*cell-border,p.x*cell+border+cell/coeff,p.y*cell+cell/2.0f,p.x*cell+border,p.y*cell+border);
            tour.closePath();
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0, 0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            } 
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }  
            g.fill(tour);
        }
    }
 
    private class Ovale implements GraphicEntity{
        Color c = Color.ORANGE; int niveau;
        public Ovale(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            float coeff = 6.0f;
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0, 0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            g.fillOval((int) (p.x*cell+border+cell/(2*coeff)),p.y*cell+border,(int) (cell-2*border-cell/coeff),cell-2*border);
        }
    }
 
    private class Larme implements GraphicEntity{
        Color c = Color.YELLOW; int niveau;
        public Larme(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            float coeff = 4.0f/5;
            GeneralPath tour = new GeneralPath();
            tour.moveTo(p.x*cell+cell/2.0f,p.y*cell+border);
            tour.lineTo((p.x+1)*cell-border,p.y*cell+border+(cell-2*border)*coeff);
            tour.curveTo((p.x+1)*cell-border,p.y*cell+border+(cell-2*border)*coeff, p.x*cell+cell/2.0f,(p.y+1)*cell,p.x*cell+border,p.y*cell+border+(cell-2*border)*coeff);
            tour.closePath();
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0, 0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            g.fill(tour);
        }
    }
 
    private class Rond implements GraphicEntity{
        Color c = Color.BLUE; int niveau;
        public Rond(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0, 0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            g.fillOval(p.x*cell+border,p.y*cell+border,cell-2*border,cell-2*border);
        }
    }
 
    private class Hexagone implements GraphicEntity{
        Color c = new Color(121, 28, 248); int niveau;
        public Hexagone(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            double d = (cell-2*border)/3.0d;
            GeneralPath tour = new GeneralPath();
            tour.moveTo(p.x*cell+border+d,p.y*cell+border);
            tour.lineTo((p.x+1)*cell-border-d,p.y*cell+border);
            tour.lineTo((p.x+1)*cell-border,p.y*cell+border+d);
            tour.lineTo((p.x+1)*cell-border,(p.y+1)*cell-border-d);
            tour.lineTo((p.x+1)*cell-border-d,(p.y+1)*cell-border);
            tour.lineTo(p.x*cell+border+d,(p.y+1)*cell-border);
            tour.lineTo(p.x*cell+border,(p.y+1)*cell-border-d);
            tour.lineTo(p.x*cell+border,p.y*cell+border+d);
            tour.closePath();
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0, 0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            g.fill(tour);
        }
    }
 
    private class Saucisse implements GraphicEntity{
        Color c = Color.RED; int niveau;
        public Saucisse(int niveau){this.niveau = niveau;}
        public void paint(Graphics2D g, Point p, int cell, int border){
            if(niveau==3) g.setColor(Color.WHITE);
            else g.setColor(this.c);
            double d = (cell-2*border)/3.0d;
            GeneralPath tour = new GeneralPath();
            tour.moveTo(p.x*cell+border+d,p.y*cell+border);
            tour.curveTo(p.x*cell+border+d,p.y*cell+border,p.x*cell+cell/2.0f,p.y*cell+cell/2.0f,(p.x+1)*cell-border,(p.y+1)*cell-border-d);
            tour.curveTo((p.x+1)*cell-border,(p.y+1)*cell-border-d,(p.x+1)*cell-border,(p.y+1)*cell-border,(p.x+1)*cell-border-d,(p.y+1)*cell-border);
            tour.curveTo((p.x+1)*cell-border-d,(p.y+1)*cell-border,p.x*cell+border+(cell-2*border)/2.0f-d,p.y*cell+border+d+(cell-2*border)/2.0f,p.x*cell+border,p.y*cell+border+d);
            tour.curveTo(p.x*cell+border,p.y*cell+border+d,p.x*cell+border,p.y*cell+border,p.x*cell+border+d,p.y*cell+border);
            if(this.niveau == 1){
                Point2D start = new Point2D.Float(0,0);
                Point2D end = new Point2D.Float(0, cell/rayures);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE};
                LinearGradientPaint pai = new LinearGradientPaint(start, end, dist, colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            if(this.niveau == 2){
                Point2D center = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float radius = cell/cercles;
                Point2D focus = new Point2D.Float(p.x*cell+cell/2.0f,p.y*cell+cell/2.0f);
                float[] dist = {0.45f, 0.5f};
                Color[] colors = {c, Color.WHITE,};
                RadialGradientPaint pai = new RadialGradientPaint(center,radius,focus,dist,colors, MultipleGradientPaint.CycleMethod.REPEAT);
                g.setPaint(pai);
            }
            g.fill(tour);
        }
    }
 
    private GraphicEntity[][] grid; 
    private Graphic p;
    private int border = 8, cell = 75, rayures = 4, cercles = 6;
    private KeyEvent ke;
    private MouseEvent clic;
    private JTextField jtf;
 
    private class KEDispatcher implements KeyEventDispatcher {
        public boolean dispatchKeyEvent(KeyEvent e) {
            if (e.getID() == KeyEvent.KEY_PRESSED) {
                if(e.getKeyCode() == KeyEvent.VK_RIGHT || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_PAUSE) ke = e;
              }
              return false;
         }
    }
 
    /** @deprecated */
    public void mouseClicked(MouseEvent e){
        this.setClic(e);
        synchronized(this){
            this.notify();
        }
    }
 
    /** @deprecated */
    public void mouseEntered(MouseEvent e){}
 
    /** @deprecated */
    public void mouseExited(MouseEvent e){}
 
    /** @deprecated */
    public void mousePressed(MouseEvent e){}
 
    /** @deprecated */
    public void mouseReleased(MouseEvent e){}
 
    /** @deprecated */
    public void setClic(MouseEvent e){
        this.clic = e;
    }
 
    /** Retourne un Point lorsque l'utilisateur clique sur une case. */
    public synchronized Point clicCase(){
        try{
            this.wait();
        }
        catch(InterruptedException e){}
        ((JComponent) this.clic.getSource()).transferFocusUpCycle();
        return new Point(this.clic.getX()/this.cell,this.clic.getY()/this.cell);
    }
 
    public InterfaceCC(int largeur, int hauteur){
        super("CC");
        this.grid = new GraphicEntity[largeur][hauteur];
        for(int i=0;i<grid.length;i++){
            for(int j=0;j<grid[i].length;j++){
                this.grid[i][j] = null;
            }        
        }
        this.p = new Graphic();
        this.p.setPreferredSize(new Dimension(largeur*this.cell, hauteur*this.cell));
        this.p.addMouseListener(this);
        this.getContentPane().setLayout(new BorderLayout());
        this.getContentPane().add(this.p,BorderLayout.CENTER);
        //this.getContentPane().add(this.p);
        this.jtf = new JTextField(20);
        this.getContentPane().add(this.jtf,BorderLayout.SOUTH);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(false);
        this.setVisible(true);
        this.pack();
        KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        manager.addKeyEventDispatcher(new KEDispatcher());
    }
 
    /* Renvoie un entier correspondant à la touche appuyee. CENTER:pause, EAST:fleche droite, WEST:fleche gauche, SOUTH:fleche bas, NORTH:fleche haut
    Renvoie -1 si la touche appuyee n'est ni une fleche ni pause. */
    public int toucheAppuyee(){
        if(this.ke == null) return -1;
        else{
            int result = -1;
            if(this.ke.getKeyCode() == KeyEvent.VK_RIGHT) result = EAST;
            if(this.ke.getKeyCode() == KeyEvent.VK_LEFT) result = WEST;
            if(this.ke.getKeyCode() == KeyEvent.VK_DOWN) result = SOUTH;
            if(this.ke.getKeyCode() == KeyEvent.VK_UP) result = NORTH;
            if(this.ke.getKeyCode() == KeyEvent.VK_PAUSE) result = CENTER;
            this.ke = null;
            return result;
        }
    }
 
    /* Efface la case d'abscisse x et d'ordonnee y */
    public void effaceCase(int x, int y){
        this.grid[x][y] = null;
        this.miseAJour();
    }
 
    public void dessinerCarre(int x, int y, int niveau){
        this.grid[x][y] = new Carre(niveau);
        this.miseAJour();
    }
 
    public void dessinerOvale(int x, int y, int niveau){
        this.grid[x][y] = new Ovale(niveau);
        this.miseAJour();
    }
 
    public void dessinerLarme(int x, int y, int niveau){
        this.grid[x][y] = new Larme(niveau);
        this.miseAJour();
    }
 
    public void dessinerRond(int x, int y, int niveau){
        this.grid[x][y] = new Rond(niveau);
        this.miseAJour();
    }
 
    public void dessinerHexagone(int x, int y, int niveau){
        this.grid[x][y] = new Hexagone(niveau);
        this.miseAJour();
    }
 
    public void dessinerSaucisse(int x, int y, int niveau){
        this.grid[x][y] = new Saucisse(niveau);
        this.miseAJour();
    }
 
    public void miseAJour(){
        this.p.repaint();
    }
 
    private class Graphic extends JPanel{
        public void paint(Graphics gr){
            Graphics2D gr2D = (Graphics2D) gr;
            gr2D.setColor(Color.BLACK);
            gr2D.fillRect(0,0,this.getWidth(),this.getHeight());
            gr2D.setStroke(new BasicStroke(2.0f));
            //int offset = 2;
            for(int i=0;i<grid.length;i++){
                for(int j=0;j<grid[i].length;j++){
                    if(grid[i][j] != null) grid[i][j].paint(gr2D, new Point(i,j), cell, border);
                }
            }
        }
    }
 
    public void afficheMessage(String m){
        JOptionPane.showMessageDialog(this,m);
    }
 
    public void afficheTexte(String t){
        this.jtf.setText(t);
    }
}
Et voici le rendu de l'interface :

Nom : 92d5ce0e5b.png
Affichages : 1600
Taille : 51,2 Ko

Je dois finir cette application pour le début de semaine prochaine et étant bloqué, ça va être difficile de le terminer à temps. Donc si quelqu'un se sent de me donner un coup de main, je suis prêt à envisager une compensation !

Merci d'avance pour votre aide.