Shuffle Array using GUI buttons

Hello there!!

Has anyone used a shuffle array and if so how did you make it work? Here is my base PG:

https://www.babylonjs-playground.com/#VBTLCH#3

Around the web Ive seen it used within a regular js format but not when it comes to BJS. The code from this js file:
Memory-Game-fend/app.js at master · sandraisrael/Memory-Game-fend · GitHub has the shuffle array plus click animation pairing 2 meshes.

How do I format this within a BJS file? Thank ya!!!

:heart: :orange_heart:,
Mekaboo

I’m not sure I understand what you mean by a “shuffle array”. Can you explain it a bit more?

1 Like

Yep here is a link that can explain more:

https://www.tutorialspoint.com/what-is-fisher-yates-shuffle-in-javascript

I’m building a card like game using buttons and in doing research this is a key component in regards to doing card like games.

Ok thanks. I’m still a bit lost on your question though. Are you asking how to implement the shuffle array algorithm? Or maybe how to animate the cards? What do you mean by “format this within a BJS file”? :slight_smile:

1 Like

My apologies for the confusion :blush:

I want to implement the algorithm and animate the cards so 2 cards can sync together.

The reason why I said “format” becuase I assumed in order to make it work their had to be a certain code with BJS framework to make this work…just couldn’t use the basic JS.

Once again sorry for confusing you :purple_heart:

I’m not sure how to help with this one. The link you sent is already in JavaScript. You can use it directly, no?

If you start the animation of two cards at the same time, they should animate together. The PG you sent currently changes the rotation of the cards manually which works, but maybe you should use animations to do it.

I’m still not exactly sure what you mean by this. If you can ask specific questions like the two I tried to answer, it will be easier to help. :slight_smile:

1 Like

I assumed since it wasn’t built with Babylon that changes had to be made within the code for it to work for a Babylon based site.

I will try to implement the array within my index file and see if it works

1 Like