Discuss Scratch

Blubfisch8
New Scratcher
4 posts

Background wont change when score is met

Ive tried fixing it a bunch of times but it wont work. The code is located in the backgrounds code since i do not know how to post it on here.

Here is a link for my game https://scratch.mit.edu/projects/803465225

I hope someone can help out!
Guil1nkem
Scratcher
42 posts

Background wont change when score is met

To start it would be cool that when blobby touches a coin the coin dissapears, then what do you mean by changing the backgrounds. That each time that you touch a coin the backgrounds changes?

Waiting for your answer, *******
Majkelsien
New Scratcher
1 post

Background wont change when score is met

Hello,
I have looked at the code and I think, that you should just add an event to the the code to activate it (like when green flag clicked) and a few other things: i suggest like this
when green flag clicked
forever
if <(score) > 10> then
switch backdrop to [stage 2]
broadcast [stage 2]
end
end
And so on. And also, your score variable is a variable made only for the fish, so you have to make a new one for all sprites and swap it,. That's why it wasn't changing.
I hope I helped
PutneyCat
Scratcher
500+ posts

Background wont change when score is met

There's something a bit weird with your “Score” variable, which appears to be a “for-this-sprite-only” variable for the Blobby sprite (even though it is visible as a variable in your other sprites and the background). Only the Blobby sprite seems to be recognising the change of score.

If you use a global variable (not a for-this-sprite-only one) for the score, it should start to work.

Although I notice that the score goes up quite a bit when you touch a coin, when you may have intended it only to go up by 1 per coin.

Scratchar52
Scratcher
16 posts

Background wont change when score is met

when green flag clicked
forever
if <> then
<<> or <>><<[] < []> = []>
end
end
Blubfisch8
New Scratcher
4 posts

Background wont change when score is met

Guil1nkem wrote:

To start it would be cool that when blobby touches a coin the coin dissapears, then what do you mean by changing the backgrounds. That each time that you touch a coin the backgrounds changes?

Waiting for your answer, *******


no when the score reaches a certain point it should change
BionicBoy554
Scratcher
1000+ posts

Background wont change when score is met

i took a look inside the project and the code appears to be separated from the hat block. try putting it back
BionicBoy554
Scratcher
1000+ posts

Background wont change when score is met

and i also noticed the score changes multiple times when you get a coin.
medians
Scratcher
1000+ posts

Background wont change when score is met

This should fix it:
https://scratch.mit.edu/projects/808255144/
You might also want to disable being able to move while getting a game over by doing this:

You could also do this to set the game over to 0 instead of on the green flag script:

Ignore the wait 0 secs thing.
Also if you wanted them to not be able to move when green flag is clicked just do set game over to 1.

Last edited by medians (Feb. 22, 2023 21:47:41)

Blubfisch8
New Scratcher
4 posts

Background wont change when score is met

PutneyCat wrote:

There's something a bit weird with your “Score” variable, which appears to be a “for-this-sprite-only” variable for the Blobby sprite (even though it is visible as a variable in your other sprites and the background). Only the Blobby sprite seems to be recognising the change of score.

If you use a global variable (not a for-this-sprite-only one) for the score, it should start to work.

Although I notice that the score goes up quite a bit when you touch a coin, when you may have intended it only to go up by 1 per coin.



so i have to change the score variable to be used for all sprites? and yeah idk how to fix that either tbh im new to this
Blubfisch8
New Scratcher
4 posts

Background wont change when score is met

medians wrote:

This should fix it:
https://scratch.mit.edu/projects/808255144/
You might also want to disable being able to move while getting a game over by doing this:

You could also do this to set the game over to 0 instead of on the green flag script:

Ignore the wait 0 secs thing.
Also if you wanted them to not be able to move when green flag is clicked just do set game over to 1.


I have changed everything to match your code but it still will not change backgrounds
medians
Scratcher
1000+ posts

Background wont change when score is met

Blubfisch8 wrote:

I have changed everything to match your code but it still will not change backgrounds
It seems to work fine for me?
PutneyCat
Scratcher
500+ posts

Background wont change when score is met

Blubfisch8 wrote:

PutneyCat wrote:

There's something a bit weird with your “Score” variable, which appears to be a “for-this-sprite-only” variable for the Blobby sprite (even though it is visible as a variable in your other sprites and the background). Only the Blobby sprite seems to be recognising the change of score.

If you use a global variable (not a for-this-sprite-only one) for the score, it should start to work.

Although I notice that the score goes up quite a bit when you touch a coin, when you may have intended it only to go up by 1 per coin.



so i have to change the score variable to be used for all sprites? and yeah idk how to fix that either tbh im new to this

It can be a pain to change variables. But you can see what I mean by making some simple changes.
- Create a variable called global score (and have a green flag script set it to 0 at the beginning).
- In your Blobby sprite, add a “change global score by 1” block in the “if touching coin” bit.
- In your background script, replace Score with global score (for all three uses).
It then starts working.
coIIide
Scratcher
100+ posts

Background wont change when score is met


PutneyCat wrote:

Blubfisch8 wrote:

PutneyCat wrote:

There's something a bit weird with your “Score” variable, which appears to be a “for-this-sprite-only” variable for the Blobby sprite (even though it is visible as a variable in your other sprites and the background). Only the Blobby sprite seems to be recognising the change of score.

If you use a global variable (not a for-this-sprite-only one) for the score, it should start to work.

Although I notice that the score goes up quite a bit when you touch a coin, when you may have intended it only to go up by 1 per coin.



so i have to change the score variable to be used for all sprites? and yeah idk how to fix that either tbh im new to this

It can be a pain to change variables. But you can see what I mean by making some simple changes.
- Create a variable called global score (and have a green flag script set it to 0 at the beginning).
- In your Blobby sprite, add a “change global score by 1” block in the “if touching coin” bit.
- In your background script, replace Score with global score (for all three uses).
It then starts working.
Or you could just do
([score v] of [Blobby v])
to check the score..
medians
Scratcher
1000+ posts

Background wont change when score is met

coIIide wrote:

Or you could just do
([score v] of [Blobby v])
to check the score..
That too, though I wish there was an option not to delete all mentions of the variable when deleting the variable like before 3.0 because it was easy to then just recreate it (when I did this however, it was already in the stage so it just created a global variable of the same name so I deleted the local one).
And is this still happening? It seemed to be fixed to me.

Powered by DjangoBB