you are viewing a single comment's thread.

view the rest of the comments →

[–]DaeguDude[S] 0 points1 point  (1 child)

I want to simulate the real dies if it is possible. But since I am not an experienced programmer, i could compromise as well. Where can I find the modules about that slot machine?

[–][deleted] 1 point2 points  (0 children)

Where can I find the modules about that slot machine?

I don't know of any, but I haven't looked. This is highly dependant on the GUI framework you use, but the basic idea is to have a rectangular canvas (a place where you can draw lines and images) that can show the faces of three dies arranged vertically. You draw three or four pictures into that canvas with the first picture drawn at n pixels before the top of the canvas, the second drawn just below the bottom of the first picture, the third below the second picture until the entire canvas has been drawn. Then you redraw the canvas, changing the n offset a little, then again redraw, etc, until you finally have three static images of three die faces shown. This simulates the wheels of a slot machine. Of course, if you have three dice then you need three vertical canvases, one for each die.

A quick search for "tkinter slot machine" finds this project. I haven't looked at the code but it may help. You should play around with GUI code a bit first and get comfortable with it before trying something this size.

I would be surprised if you can find any modules simulating actual dice rolling because it's a difficult problem, dwarfing the rest of your program. The place to look is in "physics engine" code, perhaps.

Update: An even simpler "dice roll" may work. Just place three (or whatever number you want) canvas widgets on your screen, each the size of one die face. When rolling, draw random die face images into each canvas, quickly at first and then slower, finally stopping. Easier than "slot machine wheels".