Discuss Scratch

his_justin
New Scratcher
3 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
kansea
Scratcher
46 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.
his_justin
New Scratcher
3 posts

make it work pls

thanks for the suggestions
kansea
his_justin
New Scratcher
3 posts

make it work pls

now how do I implement the list code I've made?

https://scratch.mit.edu/projects/1258843661
kansea
Scratcher
46 posts

make it work pls

In your deck of cards sprite, you want something that looks like this:

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 (Today 11:35:37)

Powered by DjangoBB