As you come in… Sign in (in back) and pick up Badge Name Card – on computer… Log in: Launch/Start Alice Any questions? (of any kind) DOWNLOADS FOR TODAY:

Slides:



Advertisements
Similar presentations
SimpleGameInAlice1 Barb Ericson Georgia Institute of Technology June 2008 Creating a Simple Game in Alice.
Advertisements

As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?
Chapter 7.2 While – Conditional Loops. What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer.
Lecture 12 or President’s Day Holiday Chapter 7.2 While Loops – Finish up our race of the penguins.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Any questions? (of any kind)  Put on index.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Log in:  Launch/Start Alice  Any questions?
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Decision Structures Chapter 4. Chapter 4 Objectives To understand: o What values can be stored in a Boolean variable o What sequence structures are and.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Any questions? (of any kind)  Put on index.
Repetition Structures
Fall 2007ACS-1805 Ron McFadyen1 Ch 7 Loops Alice has two control structures for controlling the repeated execution of statements Loop While.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Lecture 8 Lab 4: It’s up! (Thursdays we post next week’s) – Plan out what you want, bring an implementation strategy diagram – Key Lab: If you’ve been.
Write Your First Computer Game!. Coding: Programming Languages Just like you can speak Chinese to someone who understands Chinese to tell them what to.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming - Putting Together the Pieces.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
As you come in…  DOWNLOADS FOR TODAY:  CarGameTeacherStarter.a2w  Online student textbook.
Chapter 7: Repetition 7.1 Definite loops (counted) 7.2 Conditional loops (indefinite)
Lecture 11 Alice Project Deliverable 1: Extension to Midnight! Midterm next class – Midterm review 4-6pm WED Pepper Canyon Hall 106 – Red scantron (1/2.
Girl Develop It Ottawa Introduction to Programming With Scratch Introduction.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
INTRODUCTION TO THE SCRATCH PROGRAMMING ENVIRONMENT.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley This week: Whew!!! The last homework was tough! The homework for this week.
Chapter 6: (Expressions,) Functions, and If/Else First we had animations – They “ran”/played the same way every time. – Neat, but a bit boring Then we.
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Making a Timer in Alice.
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
Adding Integers Welcome to the world of integers! You are about to investigate 3 different ways to add integers. Use the “Left Arrow” to go back one page.
Alice Pong Recreating Pong in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2010.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Making a Timer in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Mathematical Expressions, Conditional Statements, Control Structures
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Alice Workshop November 2009 By: Kim Glavan New Lenox School Dist #122.
Chapter 6.2 Execution Control with If/Else and Boolean Functions.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Repetition Structures Chapter 5 Part The While Instruction  Combines Loop and the condition that is also used in If/else statements  The loop.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University July 19, 2007.
Copyright 2008 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Variables & Conditions.
Obj: Programming: Simple Control Structures HW: Read section 3 – 2 AC3 D2 Do Now: 1.Log on to Alice. Open the file firstEncounter.a2w located in the folder.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Programming: Simple Control Structures Sec 46 Web Design.
Boat Racing Game Challenge #3 By Chris Brown Under the direction of Professor Susan Rodger Duke University, January 2013 Based off of the Boat Racing Game.
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.
Programming: Simple Control Structures
Programming: Simple Control Structures
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Simple Control Structures
Repetition Control Structures
Let's Race! Typing on the Home Row
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Programming: Simple Control Structures
Programming: Simple Control Structures
Simplify and identify all x-values that are undefined
Programming: Simple Control Structures
Using Functions
Using Functions in Alice
ICT Gaming Lesson 3.
Programming: Simple Control Structures
Programming: Simple Control Structures
under the direction of Professor Susan Rodger
Presentation transcript:

As you come in… Sign in (in back) and pick up Badge Name Card – on computer… Log in: Launch/Start Alice Any questions? (of any kind) DOWNLOADS FOR TODAY: CylinderStarter.a2w Online student textbook (at bottom of each page below) Module 9.2 Magnet World with Other Objects.a2w Module 9.4 SpaceShipGame.a2w

Todays plan While loops (penguin race, timer) Create your own function with a parameter (timer) Compound boolean expressions and if statements – can solve same problem multiple ways Or – car magnet And – space ship take off

Hint to getting while loops right Humans naturally think until Ill keep spending until I run out of money (balance <= 0) Ill keep dancing until I fall asleep Computers use while loops – the opposite Ill keep spending while I still have money (balance > 0) Ill keep dancing while I am not asleep While I have a dirty dish, Ill keep washing dishes

Lets have a race… A Wind up penguin (he just goes) While loop with walk and spin inside it Jet-pack penguin2 (controlled by <- event) Moves forward.5 meters Race to a stop sign (within 2 meters) Whenever someone gets within 2 meters Stop looping (going)

While loops in Alice tend to be used when… You have a user controlled (hence, not predictable) event So you dont know when the user might Click on an object Type a key, User types a number (pick a number between 1-10, etc. You have (not predictable) actions controlled by, for example, random numbers E.g. the lunchlady/zombie or fish/shark case

When should we keep going? e.g. while loop expression true (P1: wind up, P2: jet pack) CasesABCD P1, P2 outsideTTTT P1 inside, P2 outsideTTTF P2 inside, P1 outsideTTFF P1, P2 insideTFFF

Which while loop header (tile) would you use to control the going?

Lets Build the Code! Download from Meeting 4: JetPackPenguinTeacherStart.a2w Plan: Explore object positions Create event that moves jet pack penguin 0.5 meters whenever is pushed. (Test) SIMPLIFY: Create loop that makes windup penguin move repeatedly (forever), 0.35 meters (at same time as walks and windupKey rolls 0.25 revolutions) CORRECT: change loop to have the game end (e.g. windup penguin stops walking) when either penguin wins (gets within 2 meters of stop sign) WHILE:_________________________________________

Game keeps playing while… A. Either penguin is close to the stop sign B. Neither penguin is close to the stop sign What does the other one do?

Useful tool: Timer Use: to count down time in a game 2 cylinder objects set on top of each other Grey is background Yellow is in front Yellow moves down a bit each time step (loop iteration) The game is over when the yellow cylinder is Distance to the ground >= cylinder height. (So while not, game is ongoing…)

Timer Coding Plan SIMPLIFY: Loop forever (while true) move yellow cylinder down. COMPLETE: Loop should stop after yellow cylinder disappears – say should take 4 steps Hint: cylinder is 2 meters tall After loop: have 3-D Text (originally set to opacity 0) become visible saying Game Over IMPROVE: Regardless cylinder size, calculate how many steps before cylinder gone 10 steps? 4 steps? NEW PROGRAMMING CONCEPT: Functions – perform (complex) calculations

Compound Boolean Expressions – OR Car Driving Game (watch video 9.2) Modify: Car should only turn to head towards MAGNETS One of the 4 magnets Two ways if…

Compound Boolean Expressions – OR Car Driving Game Two ways if…

Compound Boolean Expressions – OR Car Driving Game Two ways if…

Compound Boolean Expressions – AND Spaceship takes off Space ship only takes off if all spheres are blue Two ways if…

Compound Boolean Expressions – AND Spaceship takes off Two ways if…

Compound Boolean Expressions – AND Spaceship takes off Two ways if…

Functions: Calculate a Value and Return it. Hides away complex calculation When program executes that line/tile: change of control flow! Jump to code/function that does the calculation It returns the calculated value, which replaces the function call tile Finally, that line/tile is executed

Examples you know Return number values: Move forward distanceTo Random Create our own – which return boolean values isAMagnet areBallsBlue

Coming Up… Week 5: Compound Boolean Expressions and if statements and while loops Week 6: Functions, Mathematical expressions, parameters, methods Week 7: Functions, parameters, methods and events Week 8: Lists