Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help With A Coin Pusher Game
- Hongle
-
Scratcher
5 posts
Help With A Coin Pusher Game
https://scratch.mit.edu/projects/149349986/
Hey, I've been working on this problem for a while now, but I can't seem to figure how to solve these problems:
1. After the original purple coin, or any one of its clones pass the blue boundary, the original starts teleporting around randomly.
2. The yellow coin says “You won a coin! Congrats!” when the game starts, when it should say that after a coin has been won.
Any help would be appreciated; thanks!
Hey, I've been working on this problem for a while now, but I can't seem to figure how to solve these problems:
1. After the original purple coin, or any one of its clones pass the blue boundary, the original starts teleporting around randomly.
2. The yellow coin says “You won a coin! Congrats!” when the game starts, when it should say that after a coin has been won.
Any help would be appreciated; thanks!
- deenfoxx
-
Scratcher
100+ posts
Help With A Coin Pusher Game
Try to backtrack. You know if it is saying “You won a coin!” it had to have gotten there from a broadcast of “trial over!”.
That means a purple coin has been cloned and Coins Won is > 0.
Looking at Coins Won, I see that is in either Original Logistics or Clone Logistics if purple coin is touching white.
So my educated guess for both problems is that you need to reset Coins Won to zero in the purple coins Init. Otherwise it is going to pass right through as already won after the first time.
That means a purple coin has been cloned and Coins Won is > 0.
Looking at Coins Won, I see that is in either Original Logistics or Clone Logistics if purple coin is touching white.
So my educated guess for both problems is that you need to reset Coins Won to zero in the purple coins Init. Otherwise it is going to pass right through as already won after the first time.
Last edited by deenfoxx (March 23, 2017 21:08:29)
- Hongle
-
Scratcher
5 posts
Help With A Coin Pusher Game
I've already set Coins Won to 0 in Init.
For future repliers, let me clarify:
The goal of this simulation is to mimic a coin pusher (like the ones in arcades). Once a yellow coin spawns, it moves down until it hits the blue boundary. It then moves a random amount (to simulate variation in friction) downwards; once it hits a purple coin, they both keep moving downwards at the same velocity, along with any coins the first purple coin happens to collide with. If a yellow coin doesn't hit a purple coin in the allotted moves it has, it simply stops, and spawns another one in a random spot with
If either the amount of coins won increases, or the amount of coins spent reaches 10, that trial ends, and another should be started, running the same code again.
For future repliers, let me clarify:
The goal of this simulation is to mimic a coin pusher (like the ones in arcades). Once a yellow coin spawns, it moves down until it hits the blue boundary. It then moves a random amount (to simulate variation in friction) downwards; once it hits a purple coin, they both keep moving downwards at the same velocity, along with any coins the first purple coin happens to collide with. If a yellow coin doesn't hit a purple coin in the allotted moves it has, it simply stops, and spawns another one in a random spot with
go to x: (pick random (-240) to (240)) y: (150)
If either the amount of coins won increases, or the amount of coins spent reaches 10, that trial ends, and another should be started, running the same code again.
- deenfoxx
-
Scratcher
100+ posts
Help With A Coin Pusher Game
I've already set Coins Won to 0 in Init.All I know is that it worked fine once I added set Coins Won to 0 in the PURPLE COINS INIT. So… Thought that might help you figure out why the Yellow Coins Init isn't getting called again.
Last edited by deenfoxx (March 23, 2017 21:31:25)
- Hongle
-
Scratcher
5 posts
Help With A Coin Pusher Game
Alright, so now the problem of the game spazzing out erratically is fixed (thanks for that
). (at least, sorry) one problem still holds: if the game encounters two “failed” trials (in which no coins were won), it ends. This should only happen when a coin is won, or the amount of coins spent is at least ten.
). (at least, sorry) one problem still holds: if the game encounters two “failed” trials (in which no coins were won), it ends. This should only happen when a coin is won, or the amount of coins spent is at least ten. - deenfoxx
-
Scratcher
100+ posts
Help With A Coin Pusher Game
Alright, so now the problem of the game spazzing out erratically is fixed (thanks for that). (at least, sorry) one problem still holds: if the game encounters two “failed” trials (in which no coins were won), it ends. This should only happen when a coin is won, or the amount of coins spent is at least ten.
Your Yellow Coin sprite only ever calls for one clone, you don't have a repeat on your Yellow Coin Sprite Original Logistics.
- Hongle
-
Scratcher
5 posts
Help With A Coin Pusher Game
Should I repeat the Original Logistics function, or the
create clone of [ myself]part?
Last edited by Hongle (March 23, 2017 22:44:00)
- deenfoxx
-
Scratcher
100+ posts
Help With A Coin Pusher Game
Not sure how you want to program it. But, I'm pretty sure that is why there are only two… the original and one clone.
- Hongle
-
Scratcher
5 posts
Help With A Coin Pusher Game
I'd like to program it so that all the yellow coin's copies spawn, one at a time, at (0, 150), but placing the repeat on the function call, or the create clone function seems to break the game…
- HoofEMP
-
Scratcher
100+ posts
Help With A Coin Pusher Game
I'd like to program it so that all the yellow coin's copies spawn, one at a time, at (0, 150), but placing the repeat on the function call, or the create clone function seems to break the game…How often was the wait between repeats?
- Discussion Forums
- » Help with Scripts
-
» Help With A Coin Pusher Game