Discuss Scratch

Shlayazace
Scratcher
4 posts

Deck of cards

Sorry if this is the wrong area, I couldn't find anything so far.

How do I script for using a deck of cards.

I want to use every card only once, but randomly.. hope that makes sense.

If I was to use a list, how do I get it to put the card in a player's hand, then delete it from the list?

Any help would be greatly received, scratch is an awesome experience

Thanks in advance
deck26
Scratcher
1000+ posts

Deck of cards

Decide how to represent the cards by number - eg hearts 1 to 13, diamonds 14 to 26 etc.

Suit is ceiling (cardnumber/13) and value is (cardnumber -1) mod 13 + 1.

You can easily select a card by choosing a random number 1 to length of list so as the list gets shorter it still works. Set a variable to that random number, copy the item from there to the player's hand and delete the item from the main list.
Shlayazace
Scratcher
4 posts

Deck of cards

deck26 wrote:

Decide how to represent the cards by number - eg hearts 1 to 13, diamonds 14 to 26 etc.

Suit is ceiling (cardnumber/13) and value is (cardnumber -1) mod 13 + 1.

You can easily select a card by choosing a random number 1 to length of list so as the list gets shorter it still works. Set a variable to that random number, copy the item from there to the player's hand and delete the item from the main list.


Thanks heaps I am just about to try this now. I had found a deck of cards that helped me create a deck. This is all pretty new to me, so I'm quite green, but I will have a go. Thanks again for your reply
Shlayazace
Scratcher
4 posts

Deck of cards

deck26 wrote:

https://scratch.mit.edu/projects/2866621/ may be of interest.

Also https://scratch.mit.edu/projects/2877257/
Wow man thanks I will have a look, was just about to post too lol but ill have a look first…
Shlayazace
Scratcher
4 posts

Deck of cards

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

Kia Ora Deck 26, first and foremost thank you so much for your replies above. I really appreciate the fact that you help people on these forums.

I have included my partial project for your perusal if you get a chance.

I have placed out where the cards should go. and that is about all that is working.

This was alot harder than I expected. I am still trying to make sure that I do not get double ups in my hands and temp decks, as it should delete from the list, but because it references the list numbers, as opposed to the costume numbers, is that why it double some of them up??

I am going to try some other typs of card games, I think I can see hw the lists work, and how I can use a list for each hand, each temp deck and also the paying field, or discard piles.

Your advice, and your games you linked are really cool. I see I have alot of learning to do.

Thanks so much for your help Deck26, you are an awesome soul.
deck26
Scratcher
1000+ posts

Deck of cards

Project not shared. Are you perhaps choosing a number between 1 and the number of cards left but forgetting to then look at the list to get the actual card number? For example, if the list is full (1-52) and item 25 is 25 there's no problem but when you remove that card if you then choose 25 again the card number woould be 26 because one item has been removed.

What you should be doing is getting a random number in the remaining card list and taking the value from that list item (not the random number) before deleting it.

Thanks for your comments.

Last edited by deck26 (March 20, 2019 10:30:17)

mannukadan
Scratcher
8 posts

Deck of cards

iam play with my playing cards
move () steps
deck26
Scratcher
1000+ posts

Deck of cards

mannukadan wrote:

iam play with my playing cards
move () steps
Please don't necropost.
dave-alt-4
Scratcher
1000+ posts

Deck of cards

super late but u can do smth like https://scratch.mit.edu/projects/589003890/

Powered by DjangoBB