You are browsing as a guest. Sign up (or log in) to start making projects!

1h 1m 3s logged

Shuffle mechanism

Today was very successful day. The two major breakthroughs are creating the boxes dynamically and shuffle the height by math.random. I am happy that I remembered, that I could use useState to make an array and use the Array.prototype.map() function to simultaneously create the different boxes. And I can change the order of the boxes with changing the order of the components in the array, sooooo, that should be quite easy to archive. The random shuffle thingi was also quite successful. I just Math.random’ed some value and floor it to 2 decimals. Then I do that for every place of the numbers array and set it as new numbers array. This will update the numbers array, because of useState and let React-Three-Fiber rerender the boxes, resulting in a shuffling. The sorting will need an async function though, or else it will be instant sorting, which isnt the goal of this sorting thing. Enough yap, back to coding, eventually, maybe.

0
3

Comments 0

No comments yet. Be the first!