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

#1 2012-10-10 22:09:32

arturpl22
New Scratcher
Registered: 2012-10-10
Posts: 1

guessing game

i need to add a script into this program that i have already which is a number game. I need a variable named play that will hold "yes" or "no" depending if the user wants to play or not a loop and a other loop inside if. I have to ask if the user wants to keep playing and if it does it starts again 

heres what i got so far

http://i.imgur.com/Wv3Yy.jpg

Offline

 

#2 2012-10-11 19:35:37

kavinda
New Scratcher
Registered: 2012-10-09
Posts: 9

Re: guessing game

implement the forever block somewhere

Offline

 

#3 2012-10-11 20:15:23

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: guessing game

when gf clicked
forever
set [correct_number v] to (pick random (1) to (10))
set [guesses v] to (0)
repeat until <(answer) = (correct_number)>
change [guesses v] by (1)
ask [Your Guess?] and wait
end
say (join [You got ] (guesses)) for (2) secs
ask [You Play again?] and wait
if <(answer) = [no]>
stop all
end
end
Something like that?

Last edited by Magnie (2012-10-11 20:58:57)

Offline

 

#4 2012-10-11 20:26:24

gfchll
Scratcher
Registered: 2012-04-21
Posts: 100+

Re: guessing game

look at mine. you can guess up to ten times, It tells the answer... look at the scripts.
http://scratch.mit.edu/projects/gfchll/2587657


HELLO EVERYBODY!

Offline

 

Board footer