Getting started with the turtle Find the latest version of this document at

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Possible Windows 8 Improvements By: Scott Hill. Improve Windows 8 Split Screen Mode The only options for split screen mode currently is to have one screen.
Mission Technology Introduction to Scratch! June 2007.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Introduction to TouchDevelop
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Computer Science 1620 Loops.
SM1205 Interactivity Topic 06: Iteration and Multiple Objects Spring 2010SCM-CityU1.
Screens naming screens and concepts Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL and.
Introduction to TouchDevelop
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Programming on the Go Chapters 1and 2 Siddharth Patel
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Introduction to Scratch!
Games. learning objectives o writing games! o understanding the built-in 2D game engine o events in games o using art (pictures, sounds)
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Fall Week 3 CSCI-141 Scott C. Johnson.  Say we want to draw the following figure ◦ How would we go about doing this?
B.A. (Mahayana Studies) Introduction to Computer Science November March Logo (Part 2) More complex procedures using parameters,
1 Loops and Branches Ch 21 and Ch18 And how you can use them to draw cool pictures!
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
Introduction to TouchDevelop
An introduction to Logo Mike Warriner Engineering Director, Google Note: This course is not an endorsement of Logo by Google. All views in this document.
Downloading and Installing Autodesk Revit 2016
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
CS Class 05 Topics  Selection: switch statement Announcements  Read pages 74-83, ,
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
I/o inputs and outputs Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet.
Loops & Graphics IP 10 Mr. Mellesmoen Recall Earlier we wrote a program listing numbers from 1 – 24 i=1 start: TextWindow.WriteLine(i) i=i+1 If.
Mathematical Expressions, Conditional Statements, Control Structures
Scripts what’s in a script – basic language concepts Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including.
Scripts what’s in a script – basic language concepts Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including.
Algorithms Writing instructions in the order they should execute.
CONTROL FLOW The order in which blocks are executed is called the “control flow” of the script So far all our scripts have just executed blocks in the.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Language Find the latest version of this document at
Aquarium Lab Series Developed by Alyce BradyAlyce Brady of Kalamazoo CollegeKalamazoo College.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
Turtle Graphics Lesson 2 1. There are 3 homeworks to complete during the six lessons of this unit. Your teacher will let you know when a homework has.
Screens naming screens and concepts v2.8 Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL.
Functions. functions: a collection of lines of code with a name that one can call. Functions can have inputs and outputs.
Conditionals.
For loops. turtle drawings – common core state standards 1.1 Innovate: Demonstrate creative thinking, construct knowledge and develop innovative products.
Functions. functions – learning targets I will be able to understand how to trace function I will be able to learn how to lavage inputs and outputs with.
Functions / Blocks.
Unit 5: Canvas Painter.
Week 3 DO NOW QUESTIONS.
Loops BIS1523 – Lecture 10.
5. Function (2) and Exercises
Java Programming: Guided Learning with Early Objects
Explain what touch develop is to your students:
While Loops BIS1523 – Lecture 12.
Learning to program with Logo
Introduction to TouchDevelop
Lesson 17: Building an App: Canvas Painter
Explain what touch develop is to your students:
Creating Functions with Parameters
Module 2 Lesson 3 Over and Over Again
Introduction to TouchDevelop
Looping Topic 4.
Explain what touch develop is to your students:
CISC101 Reminders Assignment 2 due this Friday.
Module 2 Lesson 3 Over and Over Again
Mod 2 Lesson 2 Repeating with loops
Module 2 Lesson 3 Over and Over Again
Explain what touch develop is to your students:
Presentation transcript:

getting started with the turtle Find the latest version of this document at

learning objectives o basic editor usage o basic coding skills o publishing and sharing scripts o and lots of turtle fun!

turtle programming o you control a turtle o the turtle has a pen and draws a line as it moves o you have to give commands to the turtle to move forward or turn o see LOGO for reference

square “think like the turtle”…

square forward 100

square forward 100 left turn 90 (degrees)

square forward 100 left turn 90 forward 100

square forward 100 left turn 90 forward 100 left turn 90 …

square forward 100 left turn 90 forward 100 left turn 90 forward 100 left turn 90

square forward 100 left turn 90 forward 100 left turn 90 forward 100 left turn 90 forward 100 left turn 90

scripts o a script is an app created in TouchDevelop o a script can be published to TouchDevelop so that other users can use it o a script can be exported into a Windows app or Windows Phone app.

turtle as a library o scripts use actions from other scripts o a script must be marked as ‘library’ in order to share its actions o only public actions can be shared (i.e. non private)

code editor navigate the script scroll to the bottom

tap to select

tap to delete or press backspace

loading turtle o type for ‘turtle’ in the search bar o Tap on ‘search for libraries’ o tap on ‘turtle’ from the ‘TouchDevelop Samples’ user

and we keep taping to build the code tap to add a new line

type “turtle” and insert type “init” and insert type and select

keep coding then run run your script

the turtle go back to the editor run again

select multiple lines copy to clipboard paste it!

we’ve got a square! that’s how your code should look like

custom pen o change the color of the pen libs->turtle->pen color(colors→random) o change the thickness of the pen libs->turtle->set thickness(20)

exercises o 1. change to color on each stroke o 2. draw a triangle with the turtle o 3. draw a pentagon with the turtle

publishing o publish your script to the cloud anybody can see it on internet o once published, take screenshots (optional)

1. tap here 2. tap here 3. published scripts have a unique id

run the published app take screenshot

for loops o for loop: repeats the same code multiple times definition for 0 ≤ index < count do... index starts at 0, increments by 1 on each iteration and finishes at count-1. index goes through 0, 1, 2, …, count-1

square for 0 ≤ index forward(100) turtle->left turn(90) index = 0

square for 0 ≤ index forward(100) turtle->left turn(90) index = 1

square for 0 ≤ index forward(100) turtle->left turn(90) index = 2

square for 0 ≤ index forward(100) turtle->left turn(90) index = 3

add a new line and tap on ‘for’ use number keypad or type 4

local variables o a local variable holds a value in memory; o a local variable can be read or written too. definition var x := 0 reading x->post to wall update with new value x := 5

spiral var c := 100 for 0 ≤ index forward(c) turtle->left turn(90) c := c + 5 c holds the current distance to move forward increase c by 5 so that the turtle moves a little bit more on the next iteration

if statement: executes different code based on a Boolean condition if... then... else... if.. then.. else.. true or false happens when true happens when false

random walk if math->random(2) = 0 then... else... 50% chance true or false returns a random number between 0 (included) and 2 (excluded)

random walk turtle->forward(10) if math->random(2) = 0 then turtle->left turn(90) else turtle->right turn(90)

actions functions: a collection of lines of code with a name that one can call. Functions can have inputs and outputs. action square(x : Number) returns r : Number r := x * x x is an input, it is a number r is an output, it is a number the action is called ‘square’ storing x*x into r

nested square action square(c : Number) for 0 ≤ index forward(c) turtle->left turn(90) action main() var c := 100 for 0 ≤ index square(c) c := c + 5

drawing a tree

see script /gdmw

o recreate the following turtle drawing homework 1

color gradients o create gradient effects var c := colors→linear gradient(colors→red, colors →blue, index / 3) turtle→pen color(c)

homework 2 You will create a script that uses the turtle library to draw a design of your own creation. The design itself is up to you, but it must include all of the technical elements described below. o Your drawing must be created when you run the Main function. o You must use three other functions, each of which draws something. o You must use at least one for loop and at least one if statement. o Your functions should be appropriately named, and each should do something unique. o At least one function must use a parameter, and it must be called using multiple values for that parameter. o All functions must be used more than once. Using a function within a loop works for this purpose. o You must use at least three colors, and you must change the pen thickness at least once. o Your program should terminate within a reasonable amount of time. o Ideas If you don’t know what to draw, here are a few ideas: o Try drawing a shape, then rotating the turtle some amount, and then doing it again, and so on. o Try writing functions that don’t end in the same place they started. o You can draw irregular shapes, like diamonds, isosceles triangles, or stars. o Try using the pen up and move to functions to draw the same shape on different parts of the screen. o Instead of drawing a geometric shape, draw a stick figure