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

#1 2012-06-27 13:13:31

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Do until loop

I want to make a game that will run for 5 or 10 seconds after the flag is clicked.
The user will move the cursor to catch the character and it will move elsewhere. Once the time runs out the game should stop.

First I click the green flag,
This will reset the character location to 0,0 and the timer score to 0
I then use a <forever if touching mouse-pointer> to change the score by 1
and the character will go to a random spot on the screen.
I then have a if statement to check if the timer is equal 5 or 10 and stop all.


This isnt stopping the script. Help please

Offline

 

#2 2012-06-27 13:39:28

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Do until loop

What's the exact script you are using to check?

Offline

 

#3 2012-06-27 13:42:34

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Do until loop

Just add this:

when gf clicked
wait (5) secs //Whatever.
stop all
wink

Last edited by SciTecCf (2012-06-27 13:42:48)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#4 2012-06-27 16:48:48

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Do until loop

Don't make it: if equal 5 or 10.

Make it if bigger/larger than 5 or 10. Otherwise the script will be too slow to detect the exact time.


Hai.

Offline

 

#5 2012-06-27 18:33:34

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Re: Do until loop

This is very close to what i am using some of the boxes may not be exact but the correct information is there.

From my logic until the timer reaches 10 you can do the stuff inside (which move the character randomly around the screen and counts a score when it is hovered over)
Once the timer reaches 10 it should stop moving and stop the score adding up.
Ive also tried timer < 10 still no joy.

when gf clicked
go to x:[0] y:[0]
set (score v) to [0]
reset timer
repeat until <(timer) = [10]>
  forever if [touching(mouse-pointer)]
     change (score v) by (1)
     go to x:<pick random [-240] to [240]> y:<pick random [-180] to [180]>
  end
end
stop all

Offline

 

#6 2012-06-27 21:47:25

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Do until loop

Again, don't do:

repeat until <(timer) = [10]>
Instead, do:
repeat until <(timer) > [10]>
Otherwise, it will never run the script.


Hai.

Offline

 

#7 2012-06-27 22:05:40

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Re: Do until loop

I have tried that but it still wont work.

Offline

 

#8 2012-06-27 22:11:58

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Re: Do until loop

The script keeps running and the character keeps moving and the score keeps incrementing

Offline

 

#9 2012-06-27 22:37:14

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Do until loop

Could you post the project or the script?


Hai.

Offline

 

#10 2012-06-27 22:49:00

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Re: Do until loop

http://scratch.mit.edu/projects/PierceMcGeough/2640469

There is the link
Thanks for looking

Offline

 

#11 2012-06-27 23:02:15

PierceMcGeough
New Scratcher
Registered: 2012-06-27
Posts: 8

Re: Do until loop

Got it working now. New version working.

Was told to teach this to kids on saturday and this is my first day looking at it. Any tutorials for easy kids games.

I was also told to try and find out how to make the gun shoot.

Offline

 

#12 2012-06-27 23:05:54

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Do until loop

If you look in the project files that came with the program, there are some simple games in there that you guys can look at.  smile


Hai.

Offline

 

Board footer