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?

12
13
14
15
JollyGreenGiant JollyGreenGiant

2020/5/7

#
 private void match()
    {
        if (value = firstPicked)
        {
            firstPicked = returnValue
            flipCard();
        }
        else (value = secondPicked)
        {
            secondPicked = returnValue
            flipCard();
        }
    }
JollyGreenGiant JollyGreenGiant

2020/5/7

#
Am I getting close?
danpost danpost

2020/5/7

#
JollyGreenGiant wrote...
Am I getting close?
No. value has to come from somewhere
JollyGreenGiant JollyGreenGiant

2020/5/7

#
public Card(int val)

    {

        value= val;

        front = new GreenfootImage("g"+ val +".gif");

        setImage(back);

    }

I would get the value from here.
danpost danpost

2020/5/7

#
JollyGreenGiant wrote...
<< Code Omitted >> I would get the value from here.
How would that get the values of the picked cards?
JollyGreenGiant JollyGreenGiant

2020/5/7

#
I don't know where to get the values of the picked cards.
danpost danpost

2020/5/8

#
danpost wrote...
Hint: << subject >> . << verb >> << card >> . << get value >>
For example: firstPicked.getValue()
JollyGreenGiant JollyGreenGiant

2020/5/9

#
if(firstPicked.getValue) flipcard. if(secondPicked.getValue) flipcard. if (firstPicked.geValue + secondPicke.getValue) // both card matches keep flipped. else() flipcards
JollyGreenGiant JollyGreenGiant

2020/5/9

#
So something like this?
danpost danpost

2020/5/9

#
Only check values after both cards are picked and after view timer ends. Then check the values against each other.
danpost danpost

2020/5/9

#
You would not add the two values. How would that possibly compare them? You need parenthesis, "()", after ".getValue"; so, ".getValue()".
JollyGreenGiant JollyGreenGiant

2020/5/10

#
private void match()
    {
        if (firstPicked & secondPicked.getValue())
        {
            flipCard();
             
        }
        else 
        {
            
        }
    }
JollyGreenGiant JollyGreenGiant

2020/5/10

#
I really don't know what to add here
danpost danpost

2020/5/10

#
"&" is not an operator that compares. And you cannot compare a card (firstPicked) to a value (secondPicked.getValue()).
You need to login to post a reply.
12
13
14
15