1 / 14

Creating a program to make a shape

Creating a program to make a shape. Open the chrome browser Search for Blockly Turtle. Drawing shapes using a repeat loop. Task Copy this script change the: Repeat to 3 a nd the Turn to 120 What happens?. Creating a stepping loop using the Variable i. Variable i. Step.

kane
Download Presentation

Creating a program to make a shape

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creating a program to make a shape Open the chrome browser Search for Blockly Turtle

  2. Drawing shapes using a repeat loop Task Copy this script change the: Repeat to 3 and the Turn to 120 What happens?

  3. Creating a stepping loop using the Variable i Variable i Step Upper limit (end) The VARIABLEi is a value that changes each time the loop is executed (run) A common mistake when people learn stepping loops it to misread i as a 1. You can use any letter you like Task. Copy this script. Lets change the variable to J change the upper limit to 8 and step 2. What happens? https://blockly-demo.appspot.com/static/apps/turtle/index.html#cbzn2z

  4. Using a procedure AKA subroutine • Procedures are used to complete distinct (separate) tasks • To run a procedure you need to use a call or execute command. There are many ways to solve problems This is the execute call command

  5. Using a procedure inside another Procedure (Nesting) Use the DrawSquare procedure as before. We are going to make a pattern Using the DrawSquare routine to draw petals of a flower. Create a procedure called FlowerPattern This new procedure must Repeat theDrawSquareroutine 36 times Each petal must rotate by 10 degrees https://blockly-demo.appspot.com/static/apps/turtle/index.html#wcysxu

  6. Improving our program Using random to select line colours What happens if I move the colour script here? • What happens if I put this colour script here?

  7. OK but Squares are boring! We can draw any shape if we know the Number of sides and The interior angles • You can see that there is a relationship between the number of sides and the internal angles. Look at this site

  8. Using a rule The inside angle of any shape is related to the number of sides. E.g. 4 sides = 90 degrees 360 degrees divided by the No of Sides of any shape Or to put it another way 360/the number of sides We can create a variable for the number of sides we want. Create a variable NumberOfSides Create a variable InternalAngle Set NumberOfSidesto 4 It would be useful to define the SideLengthalso create a variable to store this. Make the SideLength=30

  9. Using a mathematical rule in a Variable

  10. Use variables in your DrawShape routine This now DrawShape execute call will run the procedure if it is placed on the stage. https://blockly-demo.appspot.com/static/apps/turtle/index.html#j852aj

  11. https://blockly-demo.appspot.com/static/apps/turtle/index.html#o3gvhhhttps://blockly-demo.appspot.com/static/apps/turtle/index.html#o3gvhh Create a procedure called RunShapeArt Create a loop to create rotated repetitions of the shape. This is similar to the flower loop that you’ve already practised.

  12. Using BlocklyMinecraft

More Related