<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Colored Map of the 50 States in US (Difficulty: 3)]]></title><description><![CDATA[<h2><a class="anchor-offset" name="introduction"></a>Introduction</h2>
<p dir="auto"> </p>
<p dir="auto">The map of all 50 states in the US is a handy tool for creating interactive projects for social studies or geography. In this tutorial, you will learn to build a very basic demo that shows all 50 states in different colors. You will practice using table variables and clones along the way.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/815e47b4-8614-4e4f-a5d6-3e7778244100.gif" alt="states2.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-1-remix-the-template"></a>Step 1 - Remix the Template</h2>
<p dir="auto"> </p>
<p dir="auto">Please open the following project and remix it as your own project.</p>
<p dir="auto"><a href="http://play.creaticode.com/projects/6787f4c3b71b8505f221326c" target="_blank" rel="noopener noreferrer nofollow ugc">play.creaticode.com/projects/6787f4c3b71b8505f221326c</a></p>
<p dir="auto">This project has only one sprite called “states”. It contains the costumes of all 50 states, in pure white color. It also includes a table with these columns about each state: state, x, y, shortname, color, saturation. You will learn how to use the costumes and this table in the steps below.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/239ef38d-9ee5-4686-b68a-86d124e6cbd9.gif" alt="states.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-2-use-clone-to-display-one-state"></a>Step 2 - Use Clone to Display One State</h2>
<p dir="auto"> </p>
<p dir="auto">Next, to keep it simple, we will first try to display one state. We will need to use a clone to represent that state, and hide the original sprite itself. This way, to show more states later, we just need to add more clones.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/dc00bba9-0312-4c7c-830f-ea7e9d594dbe.png" alt="8a1a6544-d72d-4211-b7ca-d6ac4a775714-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
You can pick the costume of any state, such as “Florida”. When you run the project, you will see the map of that state at the center:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/5dd968fc-88dd-4314-8cf0-c6496721bffe.png" alt="98185cae-b14c-4883-9f60-325ef09e03fd-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-3-specify-the-state-using-clone-id"></a>Step 3 - Specify the State Using Clone ID</h2>
<p dir="auto"> </p>
<p dir="auto">In CreatiCode, when you create a clone, you can also specify a “clone ID”, which can be any text or number. This makes it easy to tell each clone to do something differently. In this step, we will set the clone ID to be 1. And when we select the costume, we will use the clone ID as the row number to read the state name from the “stateinfo” table. Since the clone ID is set to 1, we will get the first state in the table, which is “Alabama”:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/188978b8-b1bf-49c9-b228-7dca810a89d9.png" alt="5b069b9c-82ea-4ce9-878c-587ed7218b09-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
The program will show the map of Alamaba now when we run it:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/19ab1194-f50a-4c01-b69d-afdc57a32c73.png" alt="62c10244-e23e-439f-8532-a39af34d4773-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-4-move-the-clone-to-the-given-position"></a>Step 4 - Move the clone to the given position</h2>
<p dir="auto"> </p>
<p dir="auto">To show each state at its correct position, we need to read the x and y positions of that state from the table, then make the clone go there. Again, we are still using the “clone ID” as the row number to index into the table.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/722dc306-4a19-4bee-8965-a19204bb7ad5.png" alt="4fcb41a0-3b39-4cf1-a3c5-501b0be661a0-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
Now we see the Alabama state in the correct position:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/dfdef243-10b3-4933-981c-cbbcea4c4ff3.png" alt="6b655f4e-a6be-4f7a-bfb4-2482e4805e7d-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-5-add-color-to-the-state"></a>Step 5 - Add Color to the State</h2>
<p dir="auto"> </p>
<p dir="auto">We can also use color effects to change the “color” and “saturation” of the state, so that it is no longer white. We need to read these 2 columns from the table in a similar way, using clone ID as the row number:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/14f90000-6f2b-44f9-a36e-9bc35bc00141.png" alt="74020578-0c6f-4804-993d-1c5b900b5d09-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
And now the Alabama state has a nice color:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/9909ce57-cfc4-47ca-9a03-37ad95b12a12.png" alt="9bff28a5-5a02-441e-aee4-62153b054a57-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-6-print-the-short-name-abbreviation-of-the-state"></a>Step 6 - Print the Short name (Abbreviation) of the state</h2>
<p dir="auto"> </p>
<p dir="auto">Next, we can read the “shortname” column to get the 2-letter abbreviation of the state, and then “print” them at the same x and y positions. Note that this block is too wide so it is shown as 2 rows below:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/03800004-6cac-482c-a471-1abc5cae192b.png" alt="23adfa1f-aa8e-4b19-8eb0-9bbc4b6efbbe-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0c75a110-2b1e-43b2-9775-a7158144ccd9.png" alt="1fbe4b3e-3475-43a1-8591-1c15d3cadd3c-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
This is what we get now:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c2df745c-a74a-4afc-9e55-248bde7dda33.png" alt="30acd6b5-3cd0-4866-9c0c-0226b5d9008b-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-7-make-50-clones-using-a-for-loop"></a>Step 7 - Make 50 Clones Using a For-loop</h2>
<p dir="auto"> </p>
<p dir="auto">To add all 50 states, we just need to make 50 clones with clone ID going from 1 to 50. An easy way to do it is to use a for-loop like this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/5cc8a208-e39b-4e15-8364-ec5fc3c10edd.png" alt="f0a190b1-a5b3-4f2e-b6ce-f1f447d00d2a-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
This will give us a complete map:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/756487ec-0917-4fe4-8bf3-3f0f6e0ed2f5.png" alt="77a2c857-cf2a-4e20-ba89-5e8dd22e9a28-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-8-random-coloring"></a>Step 8 - Random Coloring</h2>
<p dir="auto"> </p>
<p dir="auto">If you don’t like the default color/saturation that is given, you can color the states in other ways. For example, you can use 2 random numbers for the color and saturation effects. Note that the color effect takes any number between 1 and 200 (not 100), and the saturation is a number between 1 and 100. If you don’t want to use colors that are too “strong” or “light”, you can limit the saturation between 20 and 80 like this:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4310e672-c28c-4767-a91b-42fa75dae161.png" alt="655b1769-040f-4d96-af12-48b3a71693d6-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
Now every time you run the project, you will get a new random color set:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/94008202-eabe-4dd9-918c-a9a4ea3759e8.png" alt="55b24254-a177-4baf-b01b-245415e1086f-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-9-faster-drawing-advanced"></a>Step 9 - Faster Drawing (Advanced)</h2>
<p dir="auto"> </p>
<p dir="auto">You might have noticed that it takes a few seconds to draw all 50 states. This is because after adding each clone, the playground will update the stage to reflect that. If we just want to draw all 50 states quickly, we can use a common trick that disables “screen refresh”:</p>
<p dir="auto">Define a new custom block named “add states”, and check “Run without screen refresh” on the left:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f723d44b-7ef6-45b4-8d2d-d2e62dd6cb3e.png" alt="9a56e211-3190-45d5-bd2e-c3cc0a3ab174-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
Next, move the for-loop inside the definition of this block:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/3af528ea-699d-4389-91b5-ca10498f4a2f.png" alt="ab955487-4fb1-455a-8623-98145e148539-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
Essentially, the program is running the same tasks, but the playground will not update the stage until all 50 states are added, so it is much faster:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/815e47b4-8614-4e4f-a5d6-3e7778244100.gif" alt="states2.gif" class=" img-fluid img-markdown" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="additional-challenges"></a>Additional Challenges</h2>
<p dir="auto"> </p>
<p dir="auto">You can build many interesting projects based on this template. Here are some ideas for you to try:</p>
<ul>
<li>
<p dir="auto"><strong>Political Map</strong>: color each state red or blue based on its Republican or Democratic. You can either add a new column to the “stateinfo” table or use a list to store the names of all Republican states.</p>
</li>
<li>
<p dir="auto"><strong>Shift the short name</strong>: Currently the 2-letter abbreviation is printed at the center of each state. However, it does not look good for some states, such as Hawaii, Michigan, New York, Idaho, etc. You can add 2 new columns of “xshift” and “yshift” to the “stateinfo” table, and fill in how much you want to shift the 2 letters from the center of the state. For example, if you want the “HI” to be printed below the Hawaii map, you can set the yshift for the row of Hawaii to be -30, and when you print the “HI” onto the map, add the yshift to the y position of the letters.</p>
</li>
<li>
<p dir="auto"><strong>Interactive Map</strong>: You can make a state show a highlight whenever it touches the mouse pointer by changing its “brightness” color effect.</p>
</li>
<li>
<p dir="auto"><strong>Zoom-in</strong>: When a user clicks any state, you can show an enlarged version of that state and other states near by. You will not only need to change the “size” of the clone, but also scale its x and y positions.</p>
</li>
</ul>
]]></description><link>https://forum.creaticode.com/topic/1735/colored-map-of-the-50-states-in-us-difficulty-3</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 13:23:31 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/1735.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Jan 2025 19:07:30 GMT</pubDate><ttl>60</ttl></channel></rss>