Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » make it work pls
- his_justin
-
Scratcher
8 posts
make it work pls
https://scratch.mit.edu/projects/1258843661
fix it in any way you like and tell me how to finish it
but pls make it simple nothing fancy
cause I wouldnt know how to turn it into a rouge like
p.s. I want to make 21 (the game) into a rouge like
fix it in any way you like and tell me how to finish it
but pls make it simple nothing fancy
cause I wouldnt know how to turn it into a rouge like
p.s. I want to make 21 (the game) into a rouge like
- kansea
-
Scratcher
72 posts
make it work pls
It looks like you have a solid start. Be warned… I used to play blackjack quite a bit long ago. Being very familiar with the rules is important if you're going to make it.
First some recommendations for what you already have:
1. Use one sprite for your deck of cards. You only really need/want one sprite with all the card costumes in it.
2. Create a list and add all the costumes to it. You should be able to do this in code. Use a repeat(52) to cycle through all the costumes and add each one to the list.
3. When you deal a card, you pick a random number from the list. pick random from 1 - (length of list). Then REMOVE that card from the list so it can't be reused.
Next you need to detect whether the player goes over 21, whether the dealer goes over 21, whether the player or dealer wins, or whether they draw (tie).
That's about it for the basics. If you want to get really accurate, which is COMPLETELY OPTIONAL, you can add extra mechanics: doubling down (possibly with limited rules), splitting (possibly with limited rules), surrendering (seemingly rare in casinos these days except in single-deck shoes), insurance, forcing the dealer to hit on soft 17 and stand on hard 17… some of these only really make sense when betting (for example, insurance). But they could be useful if you want to attempt to turn it into a rogue-like.
I'm likely forgetting some things, but that's a good start for you.
First some recommendations for what you already have:
1. Use one sprite for your deck of cards. You only really need/want one sprite with all the card costumes in it.
2. Create a list and add all the costumes to it. You should be able to do this in code. Use a repeat(52) to cycle through all the costumes and add each one to the list.
3. When you deal a card, you pick a random number from the list. pick random from 1 - (length of list). Then REMOVE that card from the list so it can't be reused.
Next you need to detect whether the player goes over 21, whether the dealer goes over 21, whether the player or dealer wins, or whether they draw (tie).
That's about it for the basics. If you want to get really accurate, which is COMPLETELY OPTIONAL, you can add extra mechanics: doubling down (possibly with limited rules), splitting (possibly with limited rules), surrendering (seemingly rare in casinos these days except in single-deck shoes), insurance, forcing the dealer to hit on soft 17 and stand on hard 17… some of these only really make sense when betting (for example, insurance). But they could be useful if you want to attempt to turn it into a rogue-like.
I'm likely forgetting some things, but that's a good start for you.
- kansea
-
Scratcher
72 posts
make it work pls
In your deck of cards sprite, you want something that looks like this:
then you deal a card with something like this in the right place:
What this does is it gets a random number from the available cards list (stored in a variable called “random” here). Then it uses that number to set the card (the costume name of the card), then removes that number from the list of available cards. You then use the “card” variable to set the card's costume.
when green flag clicked
delete all of [available #s v]
switch costume to [costume52 v]
repeat (52)
next costume
add (costume [name v]) to [available #s v]
end
then you deal a card with something like this in the right place:
set [random v] to (pick random (1) to (length of [available #s v] :: list))
set [card v] to (item (random) of [available #s v] :: list)
delete (random) of [available #s v]
What this does is it gets a random number from the available cards list (stored in a variable called “random” here). Then it uses that number to set the card (the costume name of the card), then removes that number from the list of available cards. You then use the “card” variable to set the card's costume.
Last edited by kansea (Dec. 24, 2025 11:35:37)
- kansea
-
Scratcher
72 posts
make it work pls
Looks good! Two things:
1. You're accidentally setting the random variable twice. On the green flag block where you pick the random number, the second “set” block should be “set card”, not “set random”. Easy mistake. I often forget to change the variable name until I realize something isn't working correctly.
2. I would strongly recommend putting all the green flag blocks into a SINGLE green flag. Be careful that things are in the right order. Example: You don't want to choose a random number until AFTER you have added all the costumes to the available #s list.
1. You're accidentally setting the random variable twice. On the green flag block where you pick the random number, the second “set” block should be “set card”, not “set random”. Easy mistake. I often forget to change the variable name until I realize something isn't working correctly.

2. I would strongly recommend putting all the green flag blocks into a SINGLE green flag. Be careful that things are in the right order. Example: You don't want to choose a random number until AFTER you have added all the costumes to the available #s list.
- kansea
-
Scratcher
72 posts
make it work pls
Looks like your next steps are:
1. If the player's total is greater than 21, the player loses (but the dealer doesn't necessarily win).
2. Make the stand button work. You're doing the broadcast. Next step is to “switch sides” so that it becomes the dealer's turn to hit or stand.
1. If the player's total is greater than 21, the player loses (but the dealer doesn't necessarily win).
2. Make the stand button work. You're doing the broadcast. Next step is to “switch sides” so that it becomes the dealer's turn to hit or stand.
- Discussion Forums
- » Help with Scripts
-
» make it work pls