Learn Alice in FREE step-by-step lessons.
Unit III: Control Structures

In this lesson, you will create procedures. Procedures let you write code for an object to perform an action.
For instance, you can write a procedure for a biped to wave. Then, whenever you want a character to wave, you just call the procedure.
The code can then be used many times and for many objects. This will allow you to decompose a program into functional subprograms and create and test larger programs.
We will also use parameters so that we can tell the procedure how fast to wave, or how many times to wave. We can also use parameters to tell who the bunny faces when they wave.
This a very powerful tool and will let you greatly improve the efficiency of your code.
In this chapter, you will learn how to create class procedures that allow objects to perform actions such as walking or jumping. You will explore the advantages of procedures and learn how they make it possible to organize a program into smaller, functional subprograms that can be reused many times and with different objects. You will also learn how to use parameters to provide information to a procedure, allowing the same procedure to perform an action at different speeds, distances, or numbers of repetitions. In addition, you will use parameters to pass objects, such as markers or other 3D objects, to a procedure. These techniques will help you create programs that are more organized, flexible, and easier to modify.
Objectives:
- Write code to animate a character, then convert that code to a procedure so that it can be used many times and for other characters.
- Utilize parameters for flexibility.
- Decompose a program into subprograms: myFirstMethod will be mostly calls to procedures and functions from now on.
Please study the material at each of the links below.
Loki Waves: Video shows statements for making Loki wave.
A Biped Waving Procedure: Copy the code for Loki waving to create procedure for any biped to wave.
Adding Parameters to a Procedure: Parameters are added so that we can vary the amount to wave and times to wave.
Witch casts spell: Parameters let us cast the spell on anything to change it to anything else.
Break the Spell: A Scene procedure is used to break the spell.
Make the dog crazy: Several Parameters
Anyone can walk: A procedure for a biped to walk can be used for any biped.
Self-Study Questions: What have you learned?
Active Learning: An Exercise Class: Show what have you learned- Complete Step 6: Scene Procedures for the final project.
Discussion questions: What do you think?
Glossary for Class Procedures in Alice3: Reusable Code
Full Glossary