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

#1 2012-11-08 10:51:38

kgreenbaum
New Scratcher
Registered: 2012-11-08
Posts: 4

Score won't increase

I'm creating a shooter style game where you're on safari and shoot various animals. I have a sight sprite that I've attached to the mouse pointer that plays a noise when clicked. I also have it set up so that when one of the animals is clicked, the sight sprite changes costume to be a blood spatter sprite and then back again.

I have a variable set for score, and for each of the animal sprites a script that has "when x animal clicked increase score by 1" but the score never changes.

I did an experiment where I just put a sprite with no other scripts other than the  "when x animal clicked increase score by 1" and it worked until all the scripts were run together by clicking the green flag, after which it stopped working.

Can anyone help me out please?

Offline

 

#2 2012-11-08 13:36:06

fastmapler
Scratcher
Registered: 2012-08-06
Posts: 9

Re: Score won't increase

are you using set varable?

Offline

 

#3 2012-11-08 20:43:24

shpeters
Scratcher
Registered: 2011-12-11
Posts: 100+

Re: Score won't increase

Is it possible that another script is contradicting it?


http://i.imgur.com/bboYO.pnghttp://i.imgur.com/66Yki.gifhttp://i.imgur.com/uLUsl.jpg

Offline

 

#4 2012-11-08 20:54:48

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

Re: Score won't increase

hmm... is there a "forever" block?


HELLO EVERYBODY!

Offline

 

#5 2012-11-08 21:38:44

kgreenbaum
New Scratcher
Registered: 2012-11-08
Posts: 4

Re: Score won't increase

Hey guys, I've uploaded what I have so far. Could someone maybe take a peep at it and see if they can figure out the scoring issue?

http://scratch.mit.edu/projects/kgreenbaum/2895651

Thanks!

Offline

 

#6 2012-11-08 22:54:51

shpeters
Scratcher
Registered: 2011-12-11
Posts: 100+

Re: Score won't increase

I checked it and figured out what was wrong. To fix it replace

when [object v] clicked
change [score v] by (1)
with
when gf clicked
forever
if <<mouse down?> and <touching [mouse-pointer v]?>>
change [score v] by (1)
That should fix it.


http://i.imgur.com/bboYO.pnghttp://i.imgur.com/66Yki.gifhttp://i.imgur.com/uLUsl.jpg

Offline

 

#7 2012-11-08 23:04:45

kgreenbaum
New Scratcher
Registered: 2012-11-08
Posts: 4

Re: Score won't increase

Hey shpeters, thanks so much for this. I just put it in tried it out, but now when I click on the buffalo once, I get weird high numbers like 3, and then when i click again it jumps to 8...

Offline

 

#8 2012-11-09 16:02:32

PersainCatz
Scratcher
Registered: 2012-08-17
Posts: 100+

Re: Score won't increase

did it work for you?


http://squiby.net/view/8071912.png http://squiby.net/view/8048919.png  http://squiby.net/view/8138084.png Click any!!

Offline

 

#9 2012-11-09 16:15:07

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

Re: Score won't increase

kgreenbaum wrote:

Hey shpeters, thanks so much for this. I just put it in tried it out, but now when I click on the buffalo once, I get weird high numbers like 3, and then when i click again it jumps to 8...

Well then try editing your code so that it looks like this:

when gf clicked
forever
if <mouse down?>
 if <touching [mouse-pointer v]?>//*
  change [score v] by (1)
 end
 wait until <not (mouse down?)>//*
end
* - I added this in to make is so that you can't click once and move the mouse around to shoot multiple animals.

I hope that this helps!

Last edited by ErnieParke (2012-11-09 16:17:12)


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

Offline

 

#10 2012-11-09 16:17:22

shpeters
Scratcher
Registered: 2011-12-11
Posts: 100+

Re: Score won't increase

kgreenbaum wrote:

Hey shpeters, thanks so much for this. I just put it in tried it out, but now when I click on the buffalo once, I get weird high numbers like 3, and then when i click again it jumps to 8...

Sorry, I forgot to add the cool down. What is happening is the score is increasing because you are holding the shoot down for a few second. Here is the fixed version:

when gf clicked
forever
if <<mouse down?> and <touching [mouse-pointer v]?>>
change [score v] by (1)
wait (1) secs


http://i.imgur.com/bboYO.pnghttp://i.imgur.com/66Yki.gifhttp://i.imgur.com/uLUsl.jpg

Offline

 

#11 2012-11-09 21:09:32

kgreenbaum
New Scratcher
Registered: 2012-11-08
Posts: 4

Re: Score won't increase

Perfect thanks so much guys!!

Offline

 

Board footer