Hello all,
For my first project I am making a dice rolling game that in turn reveals 1 of 5 magic cards.
Each magic card has stats that are compared and then the winner is determined. I have written most of it, but am stuck near the end.
step 1: Asks players if they want to play
step 2: Player 1 rolls, dice answer is sent back. Player 2 rolls, dice answer is sent back.
step 3: Cards enter playing field after each roll.
step 4: (this is where I get stuck) The cards, or players, receive the rolls and then the cards are flipped and revealed as 1 of 5 cards, depending on the roll. a 6 is an instant win.
step 6: stats compared, winner determined.
Basically, I need to figure out how best to send the exact dice roll back from the dice(which is a sprite) to the stage, and then to the card (or perhaps directly to the card?)
Any help would be fantastic, and I will try to explain myself better if needed. Thank you!
Offline
How are the values of the dice rolls being stored? Is it determined by the dice's costume number? If so, you can have your card sprite use this block:
(It's located in the Sensing category)
As the value of the dice roll.
Offline
I had them just saved as variables, though I don't think it is working out as I would have liked.
How would I implement that costume# of dice piece? I think that will actually do the trick, if I can figure out how to work it in...
Offline
naboooki wrote:
I had them just saved as variables, though I don't think it is working out as I would have liked.
How would I implement that costume# of dice piece? I think that will actually do the trick, if I can figure out how to work it in...
Well you can use it like any variable, so use it that way wherever you need it. Also, just as a word of forewarning, if you use this method and if you have only 1 die sprite, then make sure that whatever scripts that require the first roll's results are run before the second roll or else your first roll will become whatever your second roll was.
Anyway, hello naboooki and welcome to Scratch! I hope that you'll have a nice time here!
Last edited by ErnieParke (2013-02-05 20:33:45)
Offline
I have also tried to add a card counter, that each roll adds to. So i have tried to select each roll through using: if cards equal to 0, 1, or 2.
perhaps this is not the best method?
And thank you for the Welcome! I am very much enjoying it so far
Offline
naboooki wrote:
my 'diceroll' variable is a local variable (apparently the only one i created), that i have set to pick a random number between 1-6.
Well that's going to cause a problem. Other than one block that nulls this, local variables can't be accessed by anything other then the sprite that owns it, so that's probably why you're having your problem. A workaround to this is:
([Local Variable v] of [VariableOwner v])
Offline
naboooki wrote:
I have also tried to add a card counter, that each roll adds to. So i have tried to select each roll through using: if cards equal to 0, 1, or 2.
perhaps this is not the best method?
And thank you for the Welcome! I am very much enjoying it so far
Well it's not the best way, though it'd work, it's close to being the best way, and it's simpler.
Also, you're welcome! Remember, if there's any problem, you can come here.
Last edited by ErnieParke (2013-02-05 20:42:17)
Offline
estile wrote:
when gf clicked forever if <([var v] of [dice v])=(1)> switch to costume [card 1 v] end
Fixed.
Last edited by ErnieParke (2013-02-05 20:57:22)
Offline
I am slightly confused as to what exactly you have written, though I think it is the right direction.
Is that what will switch the dice costume, or what is sent to change the card value?
Offline
naboooki wrote:
I am slightly confused as to what exactly you have written, though I think it is the right direction.
Is that what will switch the dice costume, or what is sent to change the card value?
It's what'll change the card's costume, though one problem I that it's doing this forever, so when the second ie roll occurs, the first card will become whatever was rolled when it shouldn't. So, it'd actually be better and simpler if you used this when you needed the card to switch costumes:
switch to costume ([Costume # v] of [Dice v])
Last edited by ErnieParke (2013-02-05 21:27:38)
Offline
Ok, I am making good progress. Thank you.
What would be the best way to work out, (after receiving a broadcast) if one variable of card 1 is greater than another variable of card 2, it is the winner?
Offline
naboooki wrote:
Ok, I am making good progress. Thank you.
What would be the best way to work out, (after receiving a broadcast) if one variable of card 1 is greater than another variable of card 2, it is the winner?
Well, if both cards have a variable saying how strong they are, then you could use this:
if <([Strength v] of [card1 v]) > ([Strength v] of [card2 v])> Player1 wins! else if <([Strength v] of [card1 v]) < ([Strength v] of [card2 v])> Player2 wins! else Tie! end end
Last edited by ErnieParke (2013-02-06 21:40:59)
Offline