CS 202 Fall 2010: Assignment 2
Homework Assignment #2 : Due Friday 9/17 before class
Drawing in Scratch
The purpose of this assignment is to familarize yourself with the Scratch programming environment by creating a simple drawing. You'll be primarily using the Motion, Pen, and Control blocks for this program.
The drawing that your program creates will be very straight-forward, consisting of just a triangle, a square, and a pentagon. After you've learned the basics of drawing in Scratch, you'll be able to create much more interesting drawings on your own or for your projects.
Specification
The program you develop must adhere to the following specification. Unfortunately, you don't have the opportunity to show much creativity in the homeworks, but the two projects will be very open ended!- Your program must consist of a single Sprite. That Sprite may have any appearance of your choosing, as long as it is not the default cat! You may draw a new costume using the Paint Tool or you may import a different Sprite.
- The Sprite must move around the Stage and use the pen instruction blocks to draw three different shapes: an equilateral triangle, a square, and a pentagon. The shapes must be drawn in that order. You can draw the shapes with any orientation you choose (e.g., "upside down" or "diagonal" is fine).
- The pen size used to draw the shapes must be at least 5 units (but may be more).
- Each shape must be a different color. You may choose any colors you like.
- The size of the shapes must be large enough that someone can identify the shapes!
- Each shape must be drawn on a different part of the stage. No shape should overlap with another or go off the edge of the Stage.
- There may be no other lines drawn on the Stage or lines connecting the shapes.
- Before drawing each shape, your Sprite must say the shape that it is drawing. For example, "I am going to draw a circle now!".
- Your program should produce the exact same output every time it runs.
- Your program must use repeat loops for drawing the sides of each shape. Drawing a triangle should use a loop that repeats 3 times; your square should use a loop that repeats 4 times; your pentagon should use a loop that repeats 5 times.
Hints
We do not anticipate that this homework will take you very long to complete. However, it is still important that you do not wait until the last minute, since unexpected problems can always occur. The skills you need to acquire in CS 202 all build from one another: you must master each homework in order to continue with the next.For each shape, you will want to put the pen down and then move steps and turn degrees to get the Sprite to draw the desired shape. You can choose the number of steps to move.
You will need to get the degrees correct for each shape. You may find it useful to remember that the interior angles of a triangle are each 60 degrees, of a square are 90 degrees, and of a pentagon are 108 degrees. The Sprite must turn to create this angle; depending upon how you code this, you may find it useful to turn the number of degrees from the perspective of a straight line or the direction the Sprite was already moving (that is, 180 degrees - interior angle degrees). You may find it helpful to draw a simple diagram of this.
In any case, test your program and see what happens when you use different numbers of steps and degrees. This is one of the great aspects of programming: you get to see the results of running your code! You don't have to get it right the first time!
When you are testing, you may find it useful to insert wait secs blocks. By pausing between blocks, you can more easily see what your Sprite is doing and perhaps what it is doing wrong!
Good luck!
Running Scratch
You are welcome to use any computing facilities for this project, as long as you have Scratch~1.4 installed. You can either download Scratch~1.4 from the website or use the Windows or Mac machines in the instructional clusters on the first floor of the Computer Sciences department. The hours and room numbers are available here.
Everyone in the class has a CS account. To activate your CS account, you go to one of the Windows machines in our instructional cluster, click on "Activate new account" and type in your UW ID number along with a new password of your choosing. You will then have an account on both the Windows and Mac clusters.
On the Windows machines, you can find Scratch in the menu for Applications.
Turning in your Homework
You should turn in this assignment through your Learn@UW account. To do this, you can follow these steps:
- Login into LearnUW : "learnuw.wisc.edu" using UW NetID and password.
- Click on the link "compsci202:Introduction to Computation" under student tab.
- Click the Dropbox option which is on Top-Left of your web page.
- Click the link to the corresponding HomeWork you need to upload. It directs you to a page where you can upload files.
- Upload the desired file and submit them. Your Scratch program will be saved in a file with the extension ".sb". For example, if you named your program "homework2", then you will see a file with the name "homework2.sb" that you should upload.
Notes: Please make your homework file's name start with "FirstnameLastname", for example, "HengGuo_Homework 2.sb". Also, please follow this format in your future submission.
If you have any questions about how to do this, please don't hesitate to ask. We don't want you to get stuck on steps like handing in your homework.
Menu
Fall 2010Time: MWF 9:55-10:45
Room: 105 Psychology
Lab: 1370 CS (1st floor)
Instructor:
Prof Andrea Arpaci-Dusseau
Office Hours Tue 2:30-3:30, Wed 11-12
Office: 7375 Computer Sciences
Email: dusseau "at" cs.wisc.edu