This site requires JavaScript, please enable it in your browser!
Greenfoot back
JollyGreenGiant
JollyGreenGiant wrote ...

2020/4/26

How do i make a simple memory card game?

9
10
11
12
13
14
15
danpost danpost

2020/5/6

#
The code in the match method should follow this format:
 
    if matching
     * rotate cards
     * if all matches found, end game
    else
     * flip cards
     * bump match count
    bump try count
    nullify picked cards
JollyGreenGiant JollyGreenGiant

2020/5/6

#
private void match()
    {
        if (matching)
        {
            rotate cards;
            if all matches found, end game;
        } 
        else
        {
            flip cards;
            bump match count;
            bump try count;
            nullify picked cards;
        }
    }
JollyGreenGiant JollyGreenGiant

2020/5/6

#
I'm having errors on lines: 6, 11, 12 and 13.
danpost danpost

2020/5/6

#
JollyGreenGiant wrote...
I'm having errors on lines: 6, 11, 12 and 13.
Did you actually think that was valid code? Surely not. It is a summary of what the method should contain. The structure and flow is good; it just needs to be put in proper syntax. Come on now. You can do it.
JollyGreenGiant JollyGreenGiant

2020/5/6

#
Did you actually think that was valid code? I did look at it and it didn't look quite right to me, but I was unsure tbh lol. I'll give it try
JollyGreenGiant JollyGreenGiant

2020/5/6

#
private void match()
    {
        if (matching)
        {
            rotate (-90);//rotate cards;
            firstPicked = c; 
            secondPicked = c;
            match();
        } 
        else
        {
            flip cards;
            bump match count;
            bump try count;
            picked =();
        }
    }
JollyGreenGiant JollyGreenGiant

2020/5/6

#
I'm still unsure, especially the else part.
danpost danpost

2020/5/6

#
JollyGreenGiant wrote...
I'm still unsure, especially the else part.
Start with line 3. What is supposed to be matching?
JollyGreenGiant JollyGreenGiant

2020/5/6

#
firstPicked and secondPicked
JollyGreenGiant JollyGreenGiant

2020/5/6

#
if (firstPicked = secondPicked)
danpost danpost

2020/5/6

#
JollyGreenGiant wrote...
firstPicked and secondPicked
No. Those are known to be two different cards. They will never be the same. Be more specific. What is supposed to be matching?
JollyGreenGiant JollyGreenGiant

2020/5/6

#
private void match()
    {
        if (firstPicked = secondPicked)
        {
            rotate cards;
            if(firstPicked = secondPicked); end game;
        } 
        else
        {
            flip cards;
            bump match count;
            bump try count;
            nullify picked cards;
        }
    }
JollyGreenGiant JollyGreenGiant

2020/5/6

#
The values of the cards
danpost danpost

2020/5/6

#
JollyGreenGiant wrote...
The values of the cards
Yes. Now, compare their values.
JollyGreenGiant JollyGreenGiant

2020/5/6

#
(fname+".gif");
There are more replies on the next page.
9
10
11
12
13
14
15