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

#1 2012-06-21 10:26:45

tennismaaan
New Scratcher
Registered: 2012-06-21
Posts: 1

Help with keeping score in a Scratch game

Hello,

I am creating a game on scratch with the following setup: There is a hammer in the center of the screen and 2 piggy banks on either side of the hammer. One of the piggy banks has coins in it, while the other one does not. The participant has to determine which piggy bank has the coins in it by understanding the pattern and hit it with the hammer. So far, I have successfully figured out how to make the hammer follow the mouse pointer, and when the hammer touches the piggy bank, the bank "breaks" and there is a scene change where the "broken bank" has coins or nothing come out of it. I would like to know how I can easily make 100 trials with alternating sides on where the correct piggy bank is located. Also, I want to make it so I can indicate the score to the participant so he knows how many he has gotten correct and on what side the correct piggy bank was on. Do you have any advice on how to approach this? Thank you!

Offline

 

#2 2012-06-21 10:41:57

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Help with keeping score in a Scratch game

Make a score variable and make sure it is showing. Then, use this in your piggy selection script to randomize the location of the correct piggy bank:

set [correct piggy bank v] to (pick random [1] to [2])
Put this in your hammer script for movement:

repeat until <<touching [your first piggy bank v]?> or <touching [your second piggy bank v]?>>
  go to [mouse-pointer v]
  if <touching [your first piggy bank v]?>
    if <(correct piggy bank) = [1]>
      change [score v] by [1]
    else
      change [score v] by [-1]
    end
  end
  if <touching [your second piggy bank v]?>
    if <(correct piggy bank) = [2]>
      change [score v] by [1]
    else
      change [score v] by [-1]
    end
  end
end
Put this at the beginning of one of your scripts:

set [score v] to [0]

Last edited by skippito (2012-06-21 10:55:22)

Offline

 

Board footer