![]() ![]() ![]() Finally, the "Point In Direction" makes sure that the Pencil sprite is properly presented upright once it's finished drawing.Next the "Change Pen Color By" will make sure that the next polygon is a different color.The "Pen Up" block prevents the sprite from leaving a trail until the user clicks on the Stage again.We know that the five exterior angles will split into equal shares of the 360-degree turn, so we can fill in the division operator to read: The Pencil sprite will draw a side length defined in the "Move" block and then "Turn" the necessary number of degrees before repeating the process as many times as there are sides. Hey guys Im working on a polygon generator that draws, for now, regular polygons and their diagonals. Now we use our newly set variables in a "Repeat" block. ![]() Next we allow the sprite to draw on the Stage by using the "Pen Down" block.It's important to set the minimum number to 3, since polygons need at least that many sides and vertices. Next the "Pick Random" blocks randomly set the side length and number of sides that our new polygon will have.It tells the sprite, " If the user clicks the mouse (or trackpad) button down, then run this code inside." If we’re not clicking, the if/then won't execute the code. Next we meet conditional testing in the form of an if/then block.This makes the sprite follow the cursor wherever it goes. The first thing inside that "Forever" loop is a command called "Go To: Mouse-Pointer".It allows the Pencil sprite do whatever instructions are inside over and over again. We set the pen width and rotation style as you can see in the preceding screenshot. The next five blocks before the "Forever" block are just for general aesthetics, and teach the Pencil sprite how it should look and act as it draws.Events are starting blocks needed to activate the entire sequence of code blocks. The "When Green Flag Clicked" block is called an event block. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |