Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Cookie Clicker Type Game
- bongolol
-
6 posts
Cookie Clicker Type Game
Im trying to code a type of golden cookies system in my game but idk how to make it so they just appear randomly
- PhiPhenomenon
-
500+ posts
Cookie Clicker Type Game
Here's some base code that you can use:
The golden cookie appears 30 to 60 seconds at a time. Then it waits until the player clicks it and awards a certain number of cookies.
Last edited by PhiPhenomenon (Jan. 4, 2024 23:39:00)
- PhiPhenomenon
-
500+ posts
Cookie Clicker Type Game
This solution does not detect if the golden cookie has been clicked, nor does it add cookies to the total count. Is this good?
- p-p-p-p-p-p-p-p-p-p-
-
1000+ posts
Cookie Clicker Type Game
The method you provided actually also does not detect is the golden cookie has been clicked - it detects whether the mouse was down and touching it. Therefor, if a player had their mouse down somewhere, and the cookie fell on it, it would be triggered, even though the mouse did not actually click the cookie. This solution does not detect if the golden cookie has been clicked, nor does it add cookies to the total count.
This also does not help because now, the user can click the cookie multiple times. Is this good?
a truly perfect script for a golden cookie would be something like this:
At least, that's how I would approach the problem.
Last edited by p-p-p-p-p-p-p-p-p-p- (Jan. 5, 2024 00:09:56)
- PhiPhenomenon
-
500+ posts
Cookie Clicker Type Game
That issue is relatively minor due to the low chance of that happening. Anyway, it can be easily fixed by adding a single block: The method you provided actually also does not detect is the golden cookie has been clicked - it detects whether the mouse was down and touching it. Therefor, if a player had their mouse down somewhere, and the cookie fell on it, it would be triggered, even though the mouse did not actually click the cookie.
- p-p-p-p-p-p-p-p-p-p-
-
1000+ posts
Cookie Clicker Type Game
That still has the same problem. The reason I know this is because I coded SWEATFit, which is a very complicated project with a lot of different assets, and one of the things I tried doing was adding buttons like this. But you can swipe them.That issue is relatively minor due to the low chance of that happening. Anyway, it can be easily fixed by adding a single block: The method you provided actually also does not detect is the golden cookie has been clicked - it detects whether the mouse was down and touching it. Therefor, if a player had their mouse down somewhere, and the cookie fell on it, it would be triggered, even though the mouse did not actually click the cookie.
I edited my original post with a foolproof solution, with no edge cases.
- bongolol
-
6 posts
Cookie Clicker Type Game
Thank you so much everyone! All this really helped!
- Discussion Forums
- » Help with Scripts
-
» Cookie Clicker Type Game