Discuss Scratch

DumbRobloxianCoder
Scratcher
5 posts

Making Upgrades For A Clicker Game

I Recently Been Attempting To Make Upgrades 1 was a success but it stops working after one more purchase what can i do and how do i make a upgrade that also stacks your cps?
legendary34678
Scratcher
1000+ posts

Making Upgrades For A Clicker Game

Does your code look like this?

when this sprite clicked
if <(points) > [49]> then
forever
change [points v] by (1)
end
end

If so, let me explain the problem with this. Do you know what the forever loop does? Well, it repeats the code inside it forever. Forever. It will not ever stop, meaning that the sprite will get stuck in the forever loop and it will not work when you click it again.

Now, what would be a better way of doing this? Well, having only one forever loop would solve the issue.

Create a variable. Let's call it “points per second.” This will start at zero.

Then, in a forever loop, change points by points per second once every second. Like so:

forever
change [points v] by (points per second)
end

Now, whenever the player buys an upgrade, all you have to do is change points per second. How convenient!
DumbRobloxianCoder
Scratcher
5 posts

Making Upgrades For A Clicker Game

@legendary34678
hey this is confusing how would i be able to make it change per second by just one variable ive only been part of scratch for half a month now im still tryna get used to how variable coding works
EpicYesMe
Scratcher
500+ posts

Making Upgrades For A Clicker Game

You can do this:

(Button Sprite)

when this sprite clicked
change [points] by (cps)

(Upgrade Sprite)

when this sprite clicked
if <points > 49> then
change [cps] by (1)
end
DumbRobloxianCoder
Scratcher
5 posts

Making Upgrades For A Clicker Game

Okay. i tested this but uhm it just doesnt do it per second
DumbRobloxianCoder
Scratcher
5 posts

Making Upgrades For A Clicker Game

I have figured it out from reply #2's code i would like to thank them
Gatekeeper24
Scratcher
1 post

Making Upgrades For A Clicker Game

so, i have 5 upgrades in my Doge Clicker game.

((Cost) * (-1))

this is the cost code i am using
my players clicks go down by -9999
for some reason. i watched a tutorial showing 2 upgrades, did that and it worked just fine, but now i decide to create a shop with no tutorial, and now i am unable to make it go down by the number of clicks the upgrade costs.

thank you for all your help!
CatClawz_
Scratcher
500+ posts

Making Upgrades For A Clicker Game

forever
wait (1) secs
change [points v] by (points per second)
end

maybe
wooper1302
Scratcher
3 posts

Making Upgrades For A Clicker Game

?

Powered by DjangoBB