Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I made a dice and a function to rotate the dice as I want.

But the the dice do not roll if the results is the same as the previous

Because I thought it would be a bit hard to imagine how it work, so I made a demo there. With full code

https://codepen.io/GinCanhViet/pen/zYjvbVX

Any one can help please.

What I have tried:

Tried make a random rotation before rotating to the desired result.

However, thie made a feeling of rotation without smooth
Posted
Updated 7-Sep-22 8:35am
v3
Comments
PIEBALDconsult 7-Sep-22 13:14pm    
No idea, and I'm not going to look at your code.
What I will say is that when I implemented a dice game, rather than just calling Roll() once per die, I did something along the lines of: for ( int i = 0 ; i < 10 ; i++ ) Roll() ; so the result was more pleasing.
GinCanhViet 7-Sep-22 13:18pm    
I think you may not understand the issue yet
GinCanhViet 7-Sep-22 13:24pm    
multi roll make the rolling not smooth, I dont wanna that
[no name] 7-Sep-22 13:31pm    
If it's doing something unwanted based on a previous result, you're obviously not "initializing" things properly for the next iteration. At the very least, "result" should be initialized to something like -1 before the next "roll" to signal an obvious "different" result (when it really isn't).
GinCanhViet 7-Sep-22 13:35pm    
Haha, thanks.
Keep doing your work! So toxic

1 solution

I have tried with few 3D js lib. It works fine but looks complicated. Then I found this guy. alexerlandsson dice on github. Still CSS but working perfectly.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900