Discuss Scratch

l0ve1y
Scratcher
100+ posts

Go Fish Card Testing

I'm in the process of creating a version of the classic card game Go Fish, and part of the process is allowing the user to view their cards at the top of the screen. What I'm currently doing is using a list to store the cards that are in the user's hand, creating costumes with different card faces, then setting the costume names to match to the value of the card (2, 3, 7, etc.) Then each time the user's hand is updated, the original card sprite creates a series of clones that switch to the value of the first card in the hand, then move 3 steps to the right until they're either not touching another card sprite, or they hit the edge (at which point they reset to the far left but set the Y value to be below the other cards.) The problem with this is sometimes when the project starts initially, one or more of the cards goes below when it's not supposed to. Furthermore, later on it almost always has a bunch of cards that are identical and don't match the cards in the user's hand (so there could be three 6s when the user only has one, or maybe there are 2 7s when the user no longer has 7s.) Occasionally, there are extra cards that don't update or change and are not part of the length value of the user's hand (e.g. showing 4 cards when the user has 3.)

All of this adds up to my question which is how can I use clones to constantly display the individual items in a list without the clones overlapping each other if the list gets too long?

“Once a wise man told me. ‘Family don’t end in blood.’ But it doesn’t start there either. Family cares about you. Not what you can do for them. Family is there for the good, bad, all of it. They got your back. Even when it hurts. That’s family” -Dean Winchester
gor-dee
Scratcher
1000+ posts

Go Fish Card Testing

l0ve1y
Scratcher
100+ posts

Go Fish Card Testing

gor-dee wrote:

Could you share a link to the project please?

https://scratch.mit.edu/projects/566511966/

“Once a wise man told me. ‘Family don’t end in blood.’ But it doesn’t start there either. Family cares about you. Not what you can do for them. Family is there for the good, bad, all of it. They got your back. Even when it hurts. That’s family” -Dean Winchester
gor-dee
Scratcher
1000+ posts

Go Fish Card Testing

The main problem I found was that you are using a global variable (cardn) which should be a local variable I think. That way each clone will have it's own ID. I made a remix here https://scratch.mit.edu/projects/618687501/editor (I've changed cardn for cardID) but as you'll see I got rid of quite a bit of code in sprite 5 to tidy it up! (the main sprite has cardID = 0, the clones will have 1,2,3 etc.)

Powered by DjangoBB