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

#1 2011-09-13 12:50:42

redstar736
New Scratcher
Registered: 2011-09-13
Posts: 2

major glitch(I think)

I'm making a project where a tennis ball appears in a random place and the dog has to fetch it. I have a script for the dog that goes like this(sorry its only in text, I don't know if I can make it look right with scratch blocks):
When green flag clicked
set stuff fetched to 0
forever if touching tennis ball
change stuff fetched by 1

But, it's only adding to the score if the tennis ball appears right on top of the dog. If I have to move the dog over to the tennis ball, it will do everything I want it to do, except add the points. This is my first game, so if I'm just making a mistake, please tell me what it is. In case you need to know, the script I use to make the tennis ball move to random locations (which does work) looks like this:
when green flag clicked
go to x: pick random -300 to 300 y: pick random -200 to 200
forever if touching fido
hide
go to x: pick random -300 to 300 y: pick random -200 to 200
wait 2 secs
show

Offline

 

#2 2011-09-13 12:55:46

redstar736
New Scratcher
Registered: 2011-09-13
Posts: 2

Re: major glitch(I think)

Is anyone going to help me?

Offline

 

#3 2011-09-13 14:33:54

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: major glitch(I think)

try use this:

go to x: pick random -300 to 300 y: pick random -200 to 200
forever if touching fido
wait 0.1 seconds
hide
go to x: pick random -300 to 300 y: pick random -200 to 200
wait 2 secs
show

Offline

 

#4 2011-09-15 18:43:00

SuperRoy
Scratcher
Registered: 2010-11-01
Posts: 8

Re: major glitch(I think)

Method 1: just wait around .05 seconds before the tennis ball disappears. that will give the dog the time it needs to register it is actually touching the ball. right now your having the ball disappear instantly so the dog doesn't have enough time to realize it is touching it.

OR

Method 2: completely get rid of the script that you listed in your fist post, and do something like this in the tennis ball's script (in a forever loop)

hide
go to x: (pick random -175 to 175) y: (pick random blah blah  big_smile )
show
wait until <touching dog>
change fetched by 1

this will make it hide, go to a random spot, show, wait until it's touching the dog, then IT adds the score, to make sure it registers it. all the dog has to do is move, make it so it's not even trying to find the ball.

Hope this helps. As a reward for helping you i get to spam this one game  wink  : http://scratch.mit.edu/projects/SuperRoy/1915446

Offline

 

Board footer