Member Avatar for Ajantis

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

Recommended Answers

All 3 Replies

This does not describes the problem you having. Do not expect people go through your coding bug fixing. Please post specific problem.

PS: Instead of using external file upload please use Manage Attachments in Advance posting options of this forum.

Member Avatar for Ajantis

This does not describes the problem you having. Do not expect people go through your coding bug fixing. Please post specific problem.

PS: Instead of using external file upload please use Manage Attachments in Advance posting options of this forum.

Ok - thanks for the info! I'll try and edit the post now. :)

Best wishes

Member Avatar for Ajantis

This does not describes the problem you having. Do not expect people go through your coding bug fixing. Please post specific problem.

PS: Instead of using external file upload please use Manage Attachments in Advance posting options of this forum.

Tried editing it - especially the file. But it seems as .ZIP files are not supported for upload. :/
Am I perhaps doing something wrong, mate?

Never-mind - seems like it works anyways. :-S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.