-
April 2nd, 2015, 07:01 PM
#1
Need assistance with java memory game
Hello,
I'm trying to compare if two pictures are the same. This is the code I have for comparing. tamponIndice is declared as a global variable. I keep getting the value of zero. How can I change it to be the previous index ?
Thanks in advance.
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
int tamponImage = 0;
int temp = 0;
for (int i = 0; i < jbtnTout.length; i++) {
if (src == jbtnTout[i]) {
click++;
if (click == 1) {
jbtnTout[i].setIcon(icon[tableauChoisi[i]]);
temp = i;
tamponImage = tableauChoisi[i];
tamponIndice = i;
}
if (click == 2) {
click = 0;
if (tableauChoisi[tamponImage] == tableauChoisi[tamponIndice]) {
jbtnTout[i].setIcon(icon[tableauChoisi[i]]);
jbtnTout[temp].setIcon(icon[tableauChoisi[temp]]);
} else if (tableauChoisi[i] != tableauChoisi[tamponIndice]) {
jbtnTout[i].setIcon(icon[0]);
jbtnTout[tamponIndice].setIcon(icon[0]);
}
}
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|