This program is to partially automate the making of 15 Puzzle
Get a Playfield from Supplies
Get another Playfield from Supplies, open its Viewer and name it cell
Get a Text from Supplies and open its Viewer
Text's numericValue, change 0.00 to 0 (no decimals)
Pick up the Text (black halo) and drop it into the cell
Reduce the size of the cell (yellow halo), we will have to fit 16 cells into the larger Playfield
Make sure the Text is inside the cell - when you move the cell the text should move with it. Also check by looking in the cell connections category, you will see the text is registered there.
Open the cell viewing menu (red halo)
Check round corners, essential for this project
Change the colour to establish contrast from the colour of the large Playfield
fill style > change colour
border style > border colour
Open the cell viewer
Add a variable, call it counter
change the value type > Player
Drag out cell counter by the assignment handle, it will form a script which reads:
cell's counter <-- dot Open the Text Viewer Get the Text to hand you a "tile representing me" (from menu at top) Replace the dot with the Text tile
Run this script briefly so the cell's counter Player type converts to a Text type. The icon on the assignment arrow will change from a dot to a text.
Now we will write a script which automatically makes new cells, increments their number and puts them into the large Playfield
Open the Playfield Viewer and drag out a script
Open the cell Viewer and drag out the cell's counter variable by the assignment handle and add it to the Playfield script. It should read:
cell's counter <-- Text To make a new cell: Go to cell > miscellaneous category, drag out cell's copy and replace Text with it
Running this will create a new copy of the cell on top of the original cell. So now we want to automatically move the new copy into the larger Playfield.
Switch on auto-line-layout in the larger Playfield, for automatic alignment:
Menu (red halo) > playfield options > check auto-line-layout
Run the script to see if new cells are populating the Playfield
For 15 Puzzle to work (later) the cells have to be touching horizontally and vertically but not diagonally. To achieve this use:
Menu (red halo) > layout > table layout > change cell inset (tricky since there are so many settings available)
To tidy up afterwards use Playfield > collections > removeAll
Now it's time to increment the numbers on the cells
Open the Text Viewer and drag in Text's numericValue by the assignment handle
Open the cell Viewer, drag out cell's counter and replace Text's with it (see diagram)
Alter this line of code to increase the numericValue by one
I think because cell counter is playing a dual role, first making a Player copy and then being a text to increment the number then it's essential to add in
cell's counter <-- Text as the third line of the script. Here's how it looks now:
Run the procedure to create a 15 Puzzle grid!
To shuffle the cells use
Playfield > collections > shuffleContents
After thought: It would look better keeping the border a different colour
Project available: 15 Puzzle Auto
Cunk on Christmas
-
Here, via Barry, is a 15½-minute video compendium of my beloved Philomena
Cunk (aka Diane Morgan) celebrating today’s holiday.
15 hours ago
No comments:
Post a Comment