Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,

Similar presentations


Presentation on theme: "Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,"— Presentation transcript:

1 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods, data, more)

2 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next Step Problem Statement Understand the problem Implement the design Test the code Design a solution

3 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Load World  Why start with a standard world for active learning?  Load from: Presentations/Worlds 3-GoodVibrationsSetUp.a2w

4 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Do in order By default, statements in the code are performed in order, but you can also create a Do in order code block.

5 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Control Statements  Alice has two fundamental control statements  Do in order perform the actions in sequence  Do together perform the actions simultaneously

6 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater First action statement

7 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 1. Select object  Start by selecting an object in the object tree (or click on the object in the scene)

8 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 2. Select methods tab  In the details panel Tabs Properties  values of object properties Procedures  methods that perform an action Functions  methods that return a value

9 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 3. Find method tile  Scroll down in methods tab

10 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater 4. Drag-n-drop Select data from drop-down menu… “turn to face” needs a target object

11 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next Step Problem Statement Understand the problem Implement the design Test the code Design a solution

12 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Play (Run)  Click the Play button

13 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater World.my first method  When Play button is clicked, the world’s my first method is executed

14 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Modify  Alice allows some optional information to modify how an action is performed.  By default a statement in Alice runs in 1 second. The duration can be changed using more…

15 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Next action  Actually, several actions

16 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Method?  No “vibrate” tile?  Method tiles built-in to Alice are simple actions  Some models have complex actions defined, e.g., walk  For other complex actions, we may create our own

17 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Decompose  How can we create our own “vibrate” method?  Decompose a complex action into simple actions garfield.vibrate do together play vibrating sound do in order garfield move up a short distance, quickly garfield move down same distance, quickly

18 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Create a new method

19 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Name the method  Name should begin with a lowercase letter and have no spaces (use camelCase, if needed)

20 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater garfield.vibrate  New method tile and editor tab

21 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Number pad  Select “other” for number pad entry

22 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Duplicate  Hold Ctrl(Alt on Mac) and drag statement down to create a duplicate

23 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Modify  Click drop-down menu to select a different (argument) value

24 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Warning???

25 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Call the method  Alice must be given an instruction to perform the actions defined in the method.

26 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Does the action performed by garfield appear to be a vibration? Why or why not?

27 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Revise Design  An object that vibrates is oscillating in a rhythmic repetition  We need to repeat the action several times garfield.vibrate do together play vibrating sound repeat 5 times do in order garfield move up a short distance, quickly garfield move down same distance, quickly

28 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Loop  Drag in Loop control tile and select “5 times”

29 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Loop control block  Drag code statements into the Loop control block  A block of program code that repeats a counted number of times.

30 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test Does the action performed by garfield appear to be a vibration? Why or why not?

31 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Revise #2  Play a sound at the same time…. garfield.vibrate do together play vibration sound loop 5 times garfield moves up a short distance, quickly garfield moves down same distance, quickly

32 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Import sound  World properties panel

33 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Imported file, timing

34 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Do together  Drag in do together code block

35 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Play sound

36 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Nested control blocks  Do in order inside do together

37 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Test  Are sound and vibration in sync?

38 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Wait  Useful for synchronizing sound and action

39 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Save  Be sure to save the world every half-hour, or so…

40 Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Textbook  More information  Coding Chapter 2, Section 2


Download ppt "Copyright 2011 Wanda Dann, Steve Cooper, Don Slater Alice Workshop Implementation Algorithm  Code World.my first method Control blocks Statements (methods,"

Similar presentations


Ads by Google