i have a memory game applet. all works fine except of one thing.
imagine you have uncoverd two cards. now my game checks, wheter they are the same (and keep uncoverd) or not. if the two cards dismatch, i want that they keep uncovered for a few seconds so that the user can keep them in mind.
for that situation i need a counter (my counter counts frames)
if the counter is different to zero, the cards are locked and the uncovered ones keep open for this time.
now i have a problem. my only method, which is permanently calles, is an update() method, from my gamemanager class. it coordinates the painting-processes of all cards and is called by paint-method of the applet-class.
therfore im forced to check or decrease the counter in this method.
so i have the following code snippet (pseudo code):
1 2 3 4 5 6 7 8
| if(wait_frames == 0) { tile1.hide(); tile2.hide(); tiles_locked = false; }
paintAllTiles() ... |
im not satisfied with this solution. not only, that in the "paint()" method i need to check every time, there are some traps in calling tileX.hide() every time again and again (btw.: tile1 and tile2 keep references to the uncovered cards);
is there any elegant way to solve my problem ?