Hello there people! :D
I am working with a lab, where we are supposed to finish a Memory Game.
We are supposed to create a "Make Move" function, and that it behaves in a
correct way. It is supposed to get the X,Y coordinates of where the user klicked,
calculate the index of the 2 dimennsional array's row and column, check if that card is
already turned, and if not, turn that card.
And THIS is what I have problem with:
The whole memory board is concidered to be like a matrix.
I tried calculating the index of the array, by using the X and Y position and dividing them with the IMG_SIZE (the set size of a card). With that given, I tried using an "if" statement to check if the card (at that row and column index which were given by the division) where the user has clicked has been taken or not. Inside the "if" statement, I have then changed it so that - should the "if" statement be false - the index where the user clicked is recognized as "turned", and the method draw(); is called - to turn the face of the card. Otherwise, should it be true, only the back of the card should be shown.
I really hope that I have explained it well. :D
Otherwise, there are PLENTY of comments inside, so I think you would understand it all. :)
I have been working a little on the "Make Move" function (resides in "MemoryPanel.java" at line 176.) but I still haven't got it working well.
If you could help me out, I would REALLY appriciate it! XD
Cheers people!
I have attached a download file along the post.
So all the project is zipped inside.
It's not that big. :) So don't worry! XD