Programming: Simple Control Structures Part 2 – Repetition Alice.

Slides:



Advertisements
Similar presentations
Recursion Alice.
Advertisements

CS320n –Visual Programming Class-level Methods and Inheritance – Part 1 Mike Scott (Slides 4-3-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger.
Class-level Methods Alice. World / Class Method World method A general method that may refer to multiple objects; not closely associated with any particular.
Class-level Methods and Inheritance Part 1 Alice.
Review of Chapter 4 Sections 1 and 2 World-level methods involve two or more objects break a large problem into smaller, logical units follow a design.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Parameters and World-level methods Alice. Our Dragon world The dragon must to take off and fly, to carry the princess.
Repetition Structures
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
Programming: Simple Control Structures Part 1 – Conditional Execution Alice.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Introducing While loops (and random numbers too) Alice.
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
Tips & Techniques 6 Random Numbers and Random Motion Alice.
Fall 2007ACS-1805 Ron McFadyen1 Chapter 3 Programming - Putting Together the Pieces.
Recursion Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we know is that repetition.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
Four Fundamental Pieces Instruction Control Structure Function Expression.
Variables and Inheritance A More Complex Example Alice.
Recursion Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we know is that repetition.
Creating An Animation Program Alice. Recall We began the animation creation process We introduced the concept of storyboard We will continue using the.
Programming: Putting Together the Pieces Built-in Questions and Expressions Alice.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Today’s Agenda 1.Collect Pre-Lab 3 2.Alice Programming Assignment 3.Built-in Functions 4.Expressions 5.Control Structure 6.Assign pair programming teams.
Programming: Simple Control Structures
Programming: Simple Control Structures MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Questions Alice. Functionality A question receives value(s), performs some computation on the value(s), and returns (sends back) a value.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
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.
Repetition: Definite Loops Sec 53 Web Design. Objectives The Student will: Understand loops and why they are used Understand definitive loops Know how.
Programming: Simple Control Structures Sec 46 Web Design.
Parameters Alice. A beetle band Our task is to create an animation for a bug band as an advertisement for their next concert.
Parameters Alice. Overview The need for more flexible methods Passing a parameter to a method Demos Using the Alice interface to write code for a parameter.
CompSci 4 Chap 4 Sec 3 Sept 23, 2010 Prof. Susan Rodger.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Class-level Methods and Inheritance Alice. Class-level Methods Some actions are naturally associated with a specific class of objects. Examples A person.
Programming: Simple Control Structures
Variables and Inheritance Part 2
Programming: Simple Control Structures
Recursion Alice.
While: Indefinite Loops
Repeating Actions.
Recursion Alice.
Parameters Alice.
Programming: Simple Control Structures
Class-level Methods Alice.
Repetition: Definite Loops
Programming: Simple Control Structures
Parameters and World-level methods
Programming: Simple Control Structures
Repetition: Definite Loops
Hundreds board counting
Programming: Simple Control Structures
Repetition: Definite Loops
Functions Alice.
Programming: Simple Control Structures
Parameters Alice.
Functions Alice.
Programming: Simple Control Structures
Class-level Methods and Inheritance
Functions Alice.
Functions Alice.
Class-level Methods and Inheritance Part 2
Variables and Inheritance A More Complex Example
Presentation transcript:

Programming: Simple Control Structures Part 2 – Repetition Alice

More complex code Up to now, our programs have used simple instructions for motion. More realistic motion requires more complex program code.

Example Let's write code to make the mummy "walk" – a somewhat stilted motion like you would see in an old Hollywood horror film. The code will be more complex because we need to alternate left and right leg motions coordinate leg motions with the body moving forward

Storyboard Do in order Do together //move body and left leg mummy move forward 0.25 meters Do in order mummy's left leg move backward mummy's left leg move forward Do together //move body and right leg mummy move forward 0.25 meters Do in order mummy's right leg move backward mummy's right leg move forward

Demo Demonstrate program development

Need for Repetition The code developed in this example makes the mummy take 1 step forward on each leg. Suppose we want the mummy to take 20 steps forward?

Possible solutions Use the clipboard to copy and paste the code again and again – sounds a bit tedious! Use a repetition control stucture.

Loop The Loop statement is a simple control structure that provides for repeating an instruction (or block of instructions) a counted number of times.

Assignment Read Chapter 3-2, pp. 66 – 72 Simple Control Structures: Loop Read Tips & Techniques 3 Engineering Look & Feel (Texture Maps, Fog) Lab 3-2 (Part 2)