2d throw dice how to implement?

Started by
5 comments, last by sefiroths 13 years, 5 months ago
I would like to develop an interface that the 2d click of a button throws of the dice.
roll the dice on the table and are seen from above the table.
I was wondering how you could implement this or if there is already a code to display this roll of the dice.
I dropped to 3d for such a thing?
programming language, preferably c, c, but if you have examples in any language are welcome

thanks
Advertisement
So, you want to click a button on your interface, which calls some kind of "dice roll" function. And this dice roll needs to be visually represented in your game/program, right?
You could either make ONE 2D Animation of a dice rolling, where you cannot actually make out which face is on top after you have rolled it. Then, you present the user some kind of close up image of the face that corresponds to your generated random number.
OR you could use this for your advantage:
http://i1.creativecow.net/u/119014/cube-layout.gif
Just use your dice as map and try to dynamically create a seamless and infinite image out of it. When you roll the dice, make the small window (that you use to look at the part of the cube map) travel with a random speed and direction. Apply some friction, the center of the window should then determine which face is finally up.

OR you could load a 3D model of your dice, create some physics (hardest part), roll it and determine which face is up.
thanks for the answer, it would be nice something like:
http://gizmodo.com/5023627/iphone-dice-g...nd-physics
Quote:Original post by sefiroths
http://gizmodo.com/5023627/iphone-dice-g...nd-physics


Google will often display truncated URLs, so one has to be careful when copy+pasting search results directly from the results page.
sorry...
http://gizmodo.com/5023627/iphone-dice-game-simulates-real-dice-rolling-using-sensors-and-physics
This is a total mix of different issues.

  • Choosing a random number from 1-6
  • Rendering a 3D scene
  • Animating a rolling die
  • Linking the animation to the resulting number on the die


  • The first is quite simple but the rest are complex topics. Looking for "code" to achieve this is not going to work.

    Break the problem down into more detailed steps than I've described and examine each step in isolation would be my advice.
    thanks for tips

    This topic is closed to new replies.

    Advertisement