Discuss Scratch

27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Hi!
I made a clicker game. I need to have a shop for buying things i.e +1 coin per click, etc. How do I make it when you buy something, it will carry over to the main gem?
Thanks!
Coder046
Scratcher
100+ posts

Clicker Game Shop

You need a
 (coins per click) 
variable to keep track of how many points one earns per click. You can also make it for all sprites so that the shop can simply change the “coins per click” variable when it needs to.
when this sprite clicked
change [Coins v] by (coins per click)
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

ok, can i send you my game link and can you go and make a remix with the correct code? Thanks
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

I searched the internet, but cant find anything
Coder046
Scratcher
100+ posts

Clicker Game Shop

Your button inside the project was labeled “coins per second,” so I did both.
Here's the project.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Thank you so much

Last edited by 27ndolieslager3 (Jan. 26, 2022 21:16:28)

Coder046
Scratcher
100+ posts

Clicker Game Shop

You're welcome! I'm glad I could help. Does everything make sense? If you don't understand something, tell me so that I can explain.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

I am confused what code you added. I want to put the code you added into my game.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Can you just send me what code you inserted? Thanks a ton
Coder046
Scratcher
100+ posts

Clicker Game Shop

Let's see.
When the green flag is clicked, everything resets, including the variables (coins per second is set to 0 and coins per click is set to 1).
When the crystal is clicked, it changes the amount of coins by the “coins per click” value. This means that it will add 2 coins every click if the coins per click value is set to 2, 3 when the variable is set to 3, etc.
The coins per second part is pretty straightforward: every second, the amount of coins is changed by the “coins per second” variable. This means that no coins will be added like this if the variable is set to 0 while one coin will be added every second if the variable is set to 1. Simply put, the script always changes the amount of coins like this and then waits for the next second (by using the “wait (1) second” block).
For the buttons themselves, I made the code simpler by checking once for if the player has enough money. If the player doesn't have enough money, then the button says “Can't Buy.” If the player does have enough money, though (because else means when the boolean inside the if statement isn't true), then the button will take the corresponding money from the player's coins.
As for the cover sprite, this is pretty simple as well. It covers the entire screen, always at the front layer so that it covers everything. It is shown, but what you can't see is that it is invisible. This is what the ghost effect is for: 0 is for completely opaque (not at all see-through), and 100 is for invisible. The forever part is only for if other sprites are changing layers, too. Now, when the project is stopped, something interesting happens. All clones are deleted, and all effects (including the ghost effect) are cleared, making the cover visible. Since the cover is covering the crystal, the player can't click the crystal when the project isn't running.

I hope this explains everything clear enough!
Coder046
Scratcher
100+ posts

Clicker Game Shop

Also, you can backpack all of the sprites, or you can save the project to your computer (using the “file” button on the top-left part of the screen). When you open your project, you actually have the ability to load the project from your computer, meaning you are able to upload the file of the fixed version to the current version.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Hm
Ok, thanks
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Also, can you add a high score to it so every player will see what the high score is on the game? Thanks for your help.
Coder046
Scratcher
100+ posts

Clicker Game Shop

Okay. Put this under the clicking script in the crystal sprite.
if <(Coins) > (☁ High Score)> then
set [☁ High Score v] to (Coins)
end
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

How do i get the cloud thing next to highscore variable?
Coder046
Scratcher
100+ posts

Clicker Game Shop

Also, you need to become a Scratcher to use cloud variables. This means commenting, sharing projects, and just being active on Scratch. The actual requirements are not officially released, but this is generally how it works.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Oh, So I need to share projects? What if there is nothing in the project?
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Well, thank you so much for the help!
Coder046
Scratcher
100+ posts

Clicker Game Shop

No; I'm not really sure how you become a Scratcher. You've already shared some projects; maybe comment. Honestly, I don't know; ask someone like @deck26 (a Scratcher who's very active on the forums) how you become a Scratcher. You could also make a new forum topic on the “Questions About Scratch” part. That would probably get you the best answer, as multiple people could and would see it.
27ndolieslager3
Scratcher
73 posts

Clicker Game Shop

Thanks a lot!

Powered by DjangoBB