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
|
public void mousePressed (MouseEvent event)
{
int c = event.getX();
int l = event.getY();
for(int i = 0; i<6; i++)
{
for(int j = 0; j<7; j++)
{
if(50+100*i<l && l<150+100*i && c<450+100*j && 350+100*j<c && plateau[i][j]==0 && placable(i, j) && !fini)
{
if(color==Color.BLUE)
{
color = Color.RED;
plateau[i][j] = 2;
}
else
{
color = Color.BLUE;
plateau[i][j] = 1;
}
array.add(new Piece(i, j, color));
fini = Jeu.fini(plateau, new Piece(i, j, color));
for(int k=0; k<i+1; k++)
{
array.remove(array.size()-1);
array.add(new Piece(k, j, color));
setArrayList(array);
repaint();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
setArrayList(array);
repaint();
}
}
}
} |
Partager