Pages: 1
Topic closed
So basically, what is 'proper' format for a Scratch Program? (I know, I know, whatever works, right?) But there must be some basic standard that works well, and can be used as a template or guideline for a simple program.
For example:
When Flag clicked: (this script may be needed in several/all sprites and possibly the stage)
.set all default variables to zero (or possibly one(1) for true/false booleans)
.set default starting position of all sprites (and graphic for background, as needed)
For a simple "Cut the deck" card game, where its a player versus the computer, a simple random number generator works well.
Create a sprite named Deck
create a variable named SelectRndCard
When 'Deck' clicked
set [SelectRndCard] to (pick random (1) to (13))
if <(selectRndCard)=1>
.switch to costume [card1]
else
.if <(selectRndCard)=2>
..switch to costume [card2]
.else
..if <(selectRndCard)=3>
...switch to costume [card3]
..else
This gets very large if there were 52 cards to choose from. Can ARRAYS be used in SCRATCH?
Could BROADCAST be used? for example
if <(selectRndCard)=1>
broadcast [card1wasSelected]
else if <(selectRndCard)=2>
broadcast [card2wasSelected]
else if...
OK, that gets really big, too. I know I'm kinda rambling on incoherently, just thinking out loud...
So, any ideas on a standardized format for programming a simple card game? I have a working 'Cut the Deck' program with just 5 random numbers, and player vs AI, but its pretty big already, with just 5 cards... So I'm open to any suggestions.
Thanks!
~Tony
Offline
There is no "proper" format. Most people have different methods, although generally programming sorta goes like this:
[Starting, reset variables to original values]-->[run beginning script]-->[run project]
(not very specific, is it?)
There is no real proper format because scratch can do a lot of things. A platforming game and a graphing project would have different beginnings...
And scratch does have arrays in lists and the item (something) of block...
Offline
Wow, you guys are fast! Thanks for the quick reply.
BWOG, I don't understand how switch to costume (SelectRndCard) would work. The variable is just a number, correct? Not the name of a costume...
I'll play with it and see what happens.
Thanks again!
Update:
OK, since I'm working on a card game, and card games are usually 'turn-based', not 'real-time', would it be recommended to have a button of some sort that ends the player turn and calls the AI turn? I guess I could add it into the scripts, something like Broadcast EndPlayerTurn, and then at the end of the AI turn, have it broadcast EndAiTurn...
Again, just thinking out loud... Hopefully this will help others who may be working on card games.
Last edited by infinitum3d (2010-03-04 14:13:50)
Offline
infinitum3d wrote:
Wow, you guys are fast! Thanks for the quick reply.
BWOG, I don't understand how switch to costume (SelectRndCard) would work. The variable is just a number, correct? Not the name of a costume...
I'll play with it and see what happens.
Thanks again!
When you make that script, the costume NUMBER and not the name is used.
Offline
Thanks guys! I see now how the costume number correlates with the SelectRndCard. As long as I have my Costume number match the random number variable, it works great!
Thats going to save me a lot of time!
Offline
Topic closed
Pages: 1