AnsonH / plinko-game

A Plinko game built with Svelte
https://plinko-web-game.netlify.app/
15 stars 6 forks source link

How to use left and right to control the path of the ball falling? #7

Closed denzhe22 closed 2 months ago

denzhe22 commented 2 months ago

I found that the server of stake will control the initial position of the ball, and whether the landing point is left or right each time. How should this be implemented?

AnsonH commented 2 months ago

Hi @denzhe22, thanks for stopping by 😄

In Stake's official implementation, they uses a server to generate a random seed (i.e. a random number) which decides the initial position of the ball.

However, my implementation doesn't use any server to keep it simple. Hence, I use this code to randomly generate the initial position. Here's a visualization of the code:

image