This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-02-05 19:47:46

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Working on my first project, and I could use some help...

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

 

#2 2013-02-05 20:12:18

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Working on my first project, and I could use some help...

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:
http://i50.tinypic.com/2ik62wx.gif
(It's located in the Sensing category)
As the value of the dice roll.


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#3 2013-02-05 20:21:03

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Re: Working on my first project, and I could use some help...

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

 

#4 2013-02-05 20:25:14

estile
Scratcher
Registered: 2013-01-26
Posts: 100+

Re: Working on my first project, and I could use some help...

are the variables "for all sprites",or "this sprite only"?


http://i45.tinypic.com/s4nvxl.png

Offline

 

#5 2013-02-05 20:29:21

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#6 2013-02-05 20:32:01

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Re: Working on my first project, and I could use some help...

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.

Offline

 

#7 2013-02-05 20:35:10

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Re: Working on my first project, and I could use some help...

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  smile

Offline

 

#8 2013-02-05 20:38:24

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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])


http://i46.tinypic.com/35ismmc.png

Offline

 

#9 2013-02-05 20:41:38

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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  smile

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.  smile

Last edited by ErnieParke (2013-02-05 20:42:17)


http://i46.tinypic.com/35ismmc.png

Offline

 

#10 2013-02-05 20:44:46

estile
Scratcher
Registered: 2013-01-26
Posts: 100+

Re: Working on my first project, and I could use some help...

when gf clicked
forever
if <(var) of (dice)=(1)>
set costume to (card 1)


http://i45.tinypic.com/s4nvxl.png

Offline

 

#11 2013-02-05 20:56:52

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#12 2013-02-05 21:08:29

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Re: Working on my first project, and I could use some help...

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

 

#13 2013-02-05 21:25:16

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#14 2013-02-05 22:16:08

naboooki
New Scratcher
Registered: 2013-02-05
Posts: 6

Re: Working on my first project, and I could use some help...

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

 

#15 2013-02-06 21:40:29

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Working on my first project, and I could use some help...

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer