+ All Categories
Home > Technology > 2.2 turtle graphics

2.2 turtle graphics

Date post: 23-Dec-2014
Category:
Upload: allenbailey
View: 2,438 times
Download: 0 times
Share this document with a friend
Description:
 
10
Microsoft® Small Basic Turtle Graphics Estimated time to complete this lesson: 1 hour
Transcript
Page 1: 2.2   turtle graphics

Microsoft® Small Basic

Turtle Graphics

Estimated time to complete this lesson: 1 hour

Page 2: 2.2   turtle graphics

In this lesson, you will learn about:

Using the Turtle object to move the Turtle on the screen.

Using the various properties and operations of the Turtle object to create graphics.

Drawing colorful designs by using the Turtle object in For..EndFor loops.

Turtle Graphics

Page 3: 2.2   turtle graphics

Meet the Turtle

You can display the Turtle by using the Show operation.

Meet your new friend in Small Basic—the Turtle! The Turtle helps you draw interesting graphics on the graphics window.

Click the button on the toolbar.

The Turtle is displayed on the screen.

Page 4: 2.2   turtle graphics

Properties and Operations of the Turtle Object

You can give commands to the Turtle by using the Turtle object. In turn, the Turtle draws graphics on the screen. Let’s look at some of these functions…

To set the location of the Turtle on the screen, you can specify the x- and y-coordinates by using the X and Y properties of the Turtle object.

To draw with the Turtle, you use the PenDown operation. If you want the Turtle to stop drawing on the screen, use the PenUp operation.

To move the Turtle for a particular distance, you can use the Move operation. Similarly, you can use the MoveTo operation, and specify the x- and y-coordinates of the location where you want the Turtle to move.

Page 5: 2.2   turtle graphics

Properties and Operations of the Turtle Object

Let’s have a look at some more functions…

To turn the Turtle by a specific angle of rotation, you can use the Angle property and define the angle of rotation in degrees. The default angle of the Turtle is 0 degrees. An angle of 0 degrees means the turtle is facing up on the screen.

To turn the Turtle, use the Turn operation. When using this operation, you define an angle in degrees. Alternatively, you can also use the TurnRight and TurnLeft operations, which turn the Turtle by 90 degrees to the right and left, respectively.

To set the speed of the Turtle, you use the Speed property. You can choose a value from 1 to 10, 1 being the slowest and 10 being the fastest.

Page 6: 2.2   turtle graphics

Making the Turtle Move

Let us start by making the Turtle draw a simple triangle on the screen.

OUTPUT

Click the button on the toolbar.

Page 7: 2.2   turtle graphics

Now that you know how to communicate with the Turtle, let’s use it for some fun activities.

Let’s use the For loop and instruct the Turtle to move and turn at specific distances and angles, creating a unique graphical design in the process.

Having Fun with the Turtle

You can use the PenColor property of the GraphicsWindow object to add color to your design.

Page 8: 2.2   turtle graphics

Having Fun with the Turtle

You can also use the Turtle to create multiple, colorful graphics on the screen. Let’s look at a program that provides our desired output.

OUTPUT

Page 9: 2.2   turtle graphics

Let’s Summarize…

Congratulations! Now you know how to:

Use the Turtle object to move the Turtle on the screen.

Use the various properties and operations of the Turtle object to create graphics.

Draw colorful designs by using the Turtle object in For..EndFor loops.

Page 10: 2.2   turtle graphics

It’s Time to Apply Your Learning…

Write a program to display a Turtle and use it to draw colorful graphics by performing the following steps:

Set the height and width of the graphics window to 400.

Use the Turtle to draw two star-shaped graphics on the screen.

Format the stars to be separate and colorful.


Recommended