If I draw a domino and and I save it as "domino.png" , where do save it? How can I use this image in the program?
Now I’m making a domino program and I don’t want to work with pre-made images but the program draws the stones and then uses them. How about this?
The Canvas has all the tools you need to draw a domino layout:
- a coordinate system
- lines
- circles
- multicorner shapes.
All you need to add is the math to lay out the dots in each domino according to the values at each end, and the math to lay out the dominoes on the board.
I totally know how to draw a domino. At the start of the program, it draws all 99 dominoes and then saves them and reloads them if needed. How do I save finished stones and how do I refill them?
I am drawing from
for my novice knowledge of dominoes game play.
To keep things simple, I recommend keeping internal data structures to keep track of the dominos, including
- domino name (00 = double blank, 23 = 2&3, 32 = 3&2 (is this supplied in the domino set?)
- domino location (in pool, in player x hand, on board at (row,column) in orientation z)
- player names and turn orders
The domino names and locations could be kept in a dictionary structure, since each domino may only be in one place at a time.
The big job here is translating the internal structure into a graphic representation of the board at any moment in the game.
I do NOT recommend making a Sprite for each and every of your pieces, instead just use one domino Sprite the player can drag and spin and click to place at his desired endpoints.
Add a few Balls as potential docking locations at the ends of the line of play to ease domino placement, similarly to how the AI2 Blocks Editor highlights docking sockets as you drag a block close to them.
After you dock, take a picture of the Canvas and use that as the new Canvas background, to make the images stick.
Does this help?