Anjuli Kannan. Google Earth Driving Simulators (3:00-7:00)

Similar documents
Teaching Kids to Program. Lesson Plan: Catch the Ball

1 Announcements (0:00 10:00) 2. 2 Excerpts from the Syllabus (10:00 15:00) 2. 4 From Last Time (18:00 20:00) 3

In this lesson you will learn: How to capture the input from the user. How to write programs using variables and lists. Athletics Swimming Gymnastics

Teacher Cheat Sheet - Game Coding Challenges

Add in a new balloon sprite, and a suitable stage backdrop.

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

Computer Science 50 Introduction to Computer Science I. Week 0

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Lost in Space. Introduction. Step 1: Animating a spaceship. Activity Checklist. You are going to learn how to program your own animation!

Lost in Space. Introduction. Scratch. You are going to learn how to program your own animation! Activity Checklist.

Making a maze with Scratch

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

Crossley Fields - Computing Vocabulary

Intensive Introduction to Computer Science. Course Overview Programming in Scratch

SCRATCH MODULE 3: NUMBER CONVERSIONS

Make a game in which you play the notes of a song as they scroll down the stage.

SCRATCH. Introduction to creative computing with Scratch 2.0

The Beauty and Joy of Computing 1 Lab Exercise 1: Introduction to Scratch/BYOB - Animations and Communication

Creating Breakout - Part 2

What you can do: Use Transparency #10

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Animate a Name Cards

All Blocks of Scratch

ICS 61 Game Systems and Design Introduction to Scratch

Telling a Story Visually. Copyright 2012, Oracle. All rights reserved.

Understanding an App s Architecture

Scratch. Creative Computing

Lesson 6 page 1. If you look at the bottom right of the Scratch color choices, you will see it say MORE BLOCKS in Purple.

1.7 Limit of a Function

Computer Science Concepts in Scratch

Computer Science Concepts in Scratch

Use the Move tool to drag A around and see how the automatically constructed objects (like G or the perpendicular and parallel lines) are updated.

S3 Scratch Programming

2. Getting Started When you start GeoGebra, you will see a version of the following window. 1

Classes, interfaces, & documentation. Review of basic building blocks

ISY00245 Principles of Programming. Module 7

Math Dr. Miller - Constructing in Sketchpad (tm) - Due via by Friday, Mar. 18, 2016

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Key Stage 2 Scratch, Python and Kodu (Beginners)

Week 1, continued. This is CS50. Harvard University. Fall Cheng Gong

Software Prototyping. & App Inventor

Magic 8-Ball. Part One: Click a Button, Hear a Sound. DESIGN: App Inventor Designer. Magic 8-Ball Predicts the Future

Rev. A 02/02/2016 Downers Grove Public Library Page 1 of 50

Not For Sale. Glossary

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Collaboration policies!

RECURSION. Week 6 Laboratory for Introduction to Programming and Algorithms Uwe R. Zimmer based on material by James Barker. Pre-Laboratory Checklist

Quick Reference Tables

Intro. Scheme Basics. scm> 5 5. scm>

EECS 482 Introduction to Operating Systems

Android Programming Family Fun Day using AppInventor

How Your First Program Works

Fall UI Design and Implementation 1

Review of Computer Science and Scratch Concepts

Microsoft PowerPoint 2016 Part 2: Notes, Links, & Graphics. Choosing a Design. Format Background

VISUAL PROGRAMMING BY SCRATCH

M O T I O N A N D D R A W I N G

BCSWomen Android programming (with AppInventor) Family fun day World record attempt

Learn to Code. App Inventor Overview

We ll be making starter projects for many of the examples, to get people started. Those should be appearing at

It s possible to get your inbox to zero and keep it there, even if you get hundreds of s a day.

Version History: 1.0: ab initio. Planning Notes:

the NXT-G programming environment

(Refer Slide Time: 01:40)

Cartoon Animation Tutorial

AppyBuilder Beginner Tutorials

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

6.001 Notes: Section 8.1

SCRATCH BUILDER R Q R O B O T C O D I N G G U I D E

Input, output, and sequence

Collaborate Ultra in D2L Brightspace Guide for Moderating and Presenting

Be careful when deciding whether to represent data as integers or floats, and be sure that you consider all possible behaviors in computation.

EXCEL + POWERPOINT. Analyzing, Visualizing, and Presenting Data-Rich Insights to Any Audience KNACK TRAINING

Dealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009

Bridges To Computing

Chapter 1: Building Blocks of Programming

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 03. REQUIREMENTS CHANGE. I Love You, You re Perfect... Now Change!

Lineup. Introduction. What you will need. Import your costumes. What you will make. What you will learn. Hardware. Software

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

WYBCS Android Programming (with AppInventor) Family fun day

Participating in a VAX University Webinar

Get comfortable using computers

We created a few different effects and animations using this technique as applied to clones.

6.001 Notes: Section 15.1

Have the students look at the editor on their computers. Refer to overhead projector as necessary.

Computer Basics: Step-by-Step Guide (Session 2)

USING AUDACITY: ROBUST, FREE, AND FULL- FEATURED SOFTWARE

The first program: Little Crab

Testing and Debugging

Scratch Programming for Primary School Teachers Quiz Game

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto

KEEPOD QUICK USER GUIDE

Lesson 3 Creating and Using Graphics

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14

HTML version of slides:

Hello App Inventor! Android programming for kids and the rest of us. Chapter 2. by Paula Beer and Carl Simmons. Copyright 2015 Manning Publications

CS50 Supersection (for those less comfortable)

Transcription:

Google Earth Driving Simulators (3:00-7:00) An example of what you can do by learning the GoogleEarth API, once you know how to write code Google has published such an API so that people can make programs for their products without having to implement every single detail themselves Check out Milktruck linked from Lecture page of website Introduction to Scratch (7:00-11:30) Scratch is a program you can use to make videos, games, animations, and interactive art You create a project in Scratch by dragging puzzle pieces from the box on the left into the palette in the center The puzzle pieces string together to perform a logical sequence of instructions for the sprite (by default a cat) to follow Oscartime (linked from the Lectures page of the website) is an example of something you can build O Hai, C! (12:30-15:30) Here s a simple program in C (Slide 50) We could explain all of this to you now, but then we would have to simultaneously be teaching you general programming concepts AND the sometimes unintuitive/confusing syntax unique to C Similarly, no matter what language we might choose to begin with, the programming concepts themselves might be lost in confusion about syntax of the language Therefore, we re going to start with Scratch, which presents instructions in English. This will allow us to focus on how to write a program and how to think algorithmically. Later we ll show you how to translate those English instructions into a language like C. Announcements (15:30-17:00) Harvard Computer Society is a student organization that promotes computing, computer science, technology, etc. You can visit their website at http:///hcs.harvard.edu. Lunch with David on Friday. If you d like to attend send an email to rsvp@cs50.net. We hope to see you there! In the interest of being green, handouts are on the web. Office hours posted on the website.

Algorithms (17:00-23:00) In order to communicate with computers, we have to think like them. In algorithms. Here s a simple algorithm to look for your socks in the morning (Slide 49) Pseudocode is in language that humans can understand, but written methodically so that it can easily be translated into real code. In step 1, we set a variable socks_on_feet to the number 0. In step 2, we enter a loop that will be repeated as long as the condition (socks_on_feet!= 2) is true. Inside the loop, we open the sock drawer, look for a sock, and then enter a condition: o If a sock is found, put it on. o Otherwise, do laundry and replenish sock drawer. This code has a bug. If only one sock is in the sock drawer, it will remain in the while loop forever. This is called an infinite loop. As you will see later, sometimes programs we write will contain infinite loops. We will recognize these cases because when we run the code, the computer will hang it will keep running and produce no output because it is stuck in a loop. This happens in real programs, too. Programs that ordinarily function properly can, in weird corner cases, descend into infinite loops. This happens even in applications you use like Mozilla Firefox or Microsoft Word. You usually deal with it by pressing Ctrl+Alt+Del or shutting down the computer. It might seem obvious to us what to do in the case where there is only one sock in the drawer, but a computer cannot make assumptions the way we can. Therefore, our algorithms must be extremely specific and precise and account for all possible cases. Nothing can be assumed. O Hai, Scratch! The Basics (23:00-39:30) When you open up a new project in scratch, you get an empty palette and a single sprite, a Cat A sprite is what will execute the instructions in your palette So, if we want the cat to say something, we drag the following pieces into the palette and put them together (Slide 52) Then when we press the green flag ( go! ) the cat says O hai, world Similarly, we can give other instructions such as Wait 1 second Stringing statements together, we write the following program, which says O hai, world 3 times waiting 1 second in between each (Slide 54) But it seems inefficient to simply repeat the same statements over and over again. This is what we call bad style. We will see how to write this more nicely in a moment.

Boolean Expressions o A Boolean expression is something that evaluates to either true or false. For instance, the following are all Boolean expressions (Slide 55) Conditions o Conditions are branches in the program that do one thing if a particular Boolean expression is true, and otherwise evaluate to false o Example (Slide 57). This meows as long as 1<2. So it will always meow. o This is a little boring. We can spice this up by picking a random number between 1 and 10 and seeing if its less than 6. This is like asking the computer to pick a random number off the top of its head. (Slide 57) Loops o Loops allow you to tell the computer to do something a set number of times, or just repeatedly forever o This program will meow every 2 seconds forever (Slide 59) o This, too, is boring. We can make it continue to meow repeatedly, but only if a certain condition is true, say, if we re touching it (Slide 59) Variables o We can use variables as placeholders for information, like in algebra o The following program simply counts up from 0, indefinitely (Slide 60) o We do this by storing the current value of our counter in the variable counter Arrays o An array is a collection of things. You can think of it like a list or vector. o (Technically they are vectors because they grow to accommodate your desired size. When you add something, to the end, it grows. C doesn t do this.) o So if we were writing an RPG, we could use an array to maintain the collection of objects that the hero is carrying around. Observe the following example (Slide 62) o This is used in FruitcraftRPG.sb, which is linked from the Lectures page of the website More Complex Scratch Concepts (39:30-56:00) Threads o We can have multiple sequences of instructions being executed at the same time, as in move2.sb. The cat and the bird are each executing a set of instructions. o (Actually, the computer is not doing multiple things at once. It is repeatedly doing a little bit of each thing really, really fast. But it can give us the illusion that it is doing two things at once.) o In a more interesting example, we have one spirte executing two threads. In Hai10.sb, one thread repeated makes the seal bark so long as the muted variable is set to false, while the other thread listens for a key press and changes the muted variable if the space bar is pressed.

o Again, we get two sets of instructions, for all practical purposes, at the same time. o Here we see an example of scripts sharing memory the variable muted. Both scripts can check and change its value. Events o Scripts can communicate with one another by broadcasting events. o One sprite will throw or trigger an event, and another sprite will listen or catch it. o For example, in Marco.sb, the girl s script executes only when it receives the event from the boy s script o We see this in programs we use every day. For instance, a browser might respond when the Esc key is pressed, because the key press triggers an event and another part of the code handles it. For examples of more complicated programs you can write, see David.sb, cherrera.sb, and others Sensors (56:00-64:00) Scratch also allows user input by means other than keyboard or mouse The pico board has a variety of sensory inputs: a button, an audio sensor, a light sensor, a lever that goes back and forth, and alligator clips Once you hook the pico board up to your computer (by USB cable), the sensing section of Scratch allows you to make use of these sensory inputs As a simple example, we have a man that appears to talk when we make sound into the sensor Check out davidwe.sb for an example of a game we can make using the lever to control position David has also written a real-world Oscartime by hooking the alligator clips up to tongs used to put a foil ball into a tin can. When the tongs touch the ball, the circuit is completed, and the alligator clips return a true to Scratch You can see a simplified version of this in Electricity.sb Breaking Down a Complex Program: Oscartime.sb (64:00-70:30) In this program, trash falls from the sky and the user must click and drag each piece of trash into Oscar s trash can. As he receives trash, Oscar counts the number of pieces that have been collected so far. The object is to collect as much trash as possible before the song finishes. At first, Oscartime might seem very complex and difficult to implement. Where would you even begin? If we were going to write such a complex program, we would first break it down into its functional and structural components to make it more manageable. What functional components must Oscartime contain? 1. Display instructions. Use a stage 2. Drop trash from the sky.

Represent trash with a gif image. Give trash a location at top of screen with a random x-coordinate. Decrease y-coordinate in a loop. 3. Detect if the mouse is hovering over trash. Use if statement. 4. Allow user to drag trash. Use if statement with mouse-down? Boolean 5. Impose time limit Control overall structure of program with Oscar sprite Have this sprite perform actions at specified time intervals Meanwhile other sprites do interesting things When Oscar sprite reaches end of script, game is over 6. Keep score To change appearance of Oscar sprite as he pops out of the can, use costume changes 7. Lift Oscar s lid to put trash in Use if statement to determine when mouse is within 40 pixels of can Now that we have identified all of the functions it must perform, we can tackle the problem one step at a time. We would start by implementing just one of the steps above, and then, as we get small pieces to work properly, put them together to grow a larger and more complex program. In this manner we could ultimately produce the finished product you see here. So we start with displaying the instructions. This is a matter of writing a short script for a sprite consisting of the instructions (say, a jpeg) that goes to a particular location, shows itself, waits, and hides itself. Next we make trash fall. How do we do this? First piece will be when green flag clicked to initiate the script. Next, position trash at top of screen: go to (0,180) To make trash move, put move 2 steps in a forever loop. Now, we test the program. It is very important to test small pieces as you build up a large program, rather than testing only at the end. This makes it easy to locate and fix bugs. An initial bug David encountered was that when we dragged a piece of trash, other pieces of trash would get picked up. Use of the variable my_click fixes this problem. From Scratch to C (70:30-72:45) We can translate all of the familiar structures from Scratch into C Hello world (Slide 77) Booleans (Slide 78) Conditions (Slide 79) Loops (Slide 80)

Variables (Slide 81) Arrays (Slide 82) This week s problem set (72:45-75:30) Implement something in Scratch. See spec for details. You can optionally use a pico board. Come to office hours to sign one out.