Peeking into Computer Science Alice Lab Manual. Lab Manual. Programming

Size: px
Start display at page:

Download "Peeking into Computer Science Alice Lab Manual. Lab Manual. Programming"

Transcription

1 Lab Manual Programming 1

2 Alice Lab 1: Introduction 2

3 Table of Contents Lab 1: Introduction... 5 The Alice Interface... 6 Objects... 6 Lab 2: Sequential & Parallel Execution Do in order Do together Further nesting Lab 3: Branching & Looping Conditional execution Relational Operators Randomness Repetition While loops Lab 4: Lists Lists Sound (optional) Lab 5: Event Handling Interactive programming & event handling Control of flow Events Event handing methods Example 1: Ice Skater Example 2: Mummy Catches Pharaoh Other types of events Lab 6: Object Oriented Programming Classes Objects Methods

4 World-level methods Class-level methods Dummy objects (optional) Method Parameters Note: All of the material in this lab manual is inspired by: Wanda Dann, Stephen Cooper, and Randy Pausch, Learning to Program with Alice, Pearson Prentice Hall, The material in this manual is developed using Alice 2.2. We recommend that you download and use this version from: Lab 1: Introduction 4

5 Lab 1: Introduction Alice is a programming language which allows programmers to easily create 3D animations and games. Programs in Alice are created by dragging objects around the screen. The scene can then be played so that the objects on the screen act out the script written for them. Exercise 1 1. Open Alice on your computer. 2. When it loads, click Start the Tutorial. 3. Go through the tutorial instructions. Lab 1: Introduction 5

6 The Alice Interface The world window: shows the world being built. 2. The object tree: contains a list of objects in the world. 3. The details area: provides further information on the world or the currently selected object. 4. The (method) editor area: allows you to make objects perform actions. 5. The events area: allows you to tell Alice when to make objects do certain things. Objects Each entity seen in the world window is an object. In this example, both the lake and the ice skater are objects. Let us examine the details of the iceskater object more closely. The details area has three tabs: Methods: As you probably understood from the previous exercise, methods are actions that an object can do. As seen below, an iceskater can be asked to skate, spin and do many more actions using methods. Lab 1: Introduction 6

7 Some methods, such as skate and move, require arguments (or parameters). Arguments are items of information that must be supplied for an action to be performed. For instance, when asking the iceskater to skate, Alice needs to know how many steps it needs to skate. Properties: characteristics of an object, such as its color and texture, are known as the object s properties. Lab 1: Introduction 7

8 Try changing the color of the iceskater to blue. By doing this, the color property of the iceskater is changed before the program runs. Change the color back to no color. If we want to change a property while an animation is running, we have to add this change to the instruction list. Assume we would like to change the iceskater s isshowing property from true to false (making the iceskater invisible), after the skater is done with her routine. To do this, we need to drag the isshowing property to the end of the instruction list and select false from the menu. Lab 1: Introduction 8

9 Try playing the scene to see the difference. Functions: While some object properties can be obtained directly through an object s properties list, others need to be obtained by using functions to ask questions about the object. Lab 1: Introduction 9

10 In other words, functions are used to obtain information about an object, not to change the property of an object. When Alice is asked a question about an object using a function, it returns a value as an answer. This value may be a number, an object, or Boolean (true/false). This is what happens behind the scenes when a function is used as a method parameter: Lab 1: Introduction 10

11 IceSkater.skate howmanysteps = iceskater s distance to tree Function calculates distance to tree. Distance is 5. IceSkater.skate howmanysteps = The calculated result is returned to where the function was called 5 The IceSkater skates 5 steps Functions can be used as arguments for methods. For instance, let us try to move the iceskater forward by the value of the height of the iceskater. Drag the iceskater move method from the method tab and drop it as the last instruction in the method editor. Lab 1: Introduction 11

12 Right now, the iceskater is asked to move forward by 0.5 meters. To change this so that the forward movement is equivalent to the iceskater s height, go to the functions tab, and drag the iceskater s height function on top of the 0.5 meters argument. Lab 1: Introduction 12

13 This instruction can now be read as: Move the iceskater forward, by the number of meters that is equivalent to the iceskater s height. The height function returns the value of the iceskater s height, and passes it as an argument to the move function. Exercise 2 1. Open the file lab1.a2w. 2. Press the Play button to see what the world does. 3. Modify the 2 nd instruction so that the shark rolls right by 2 revolutions. 4. Modify the 3 rd instruction so that the shark says I am hungry. 5. Modify the 4 th instruction so that the shark moves forward by its distance to the blueminnow3 s tail minus Using functions, modify the 1 st instruction so that the bigfish moves forward by its distance in front of the shark s jaw. 7. Using properties, make the blueminnow turn black then disappear at the end of the instruction list. 8. Using methods, make the bigfish think I should get out of here, after the blueminnow disappears. Lab 1: Introduction 13

14 Exercise 3 1. Create a new world using the green grass template. 2. Change the color of the grass to blue, so that it now looks like an ocean. 3. Add an island object (from Environments) and a goldfish (from Ocean). Make sure they are both visible. 4. Get the fish to roll left by 2 revolutions. 5. Resize the island by a scale of Using methods, let the fish say Yikes! 7. Make the fish move forward by its distance in front of the island * Change the color of the grass to dark gray. Exercise 4 Create a world using the snow template. Add two snowwomen and one snowman to the scene. A snowman is trying to meet a snowwoman who is talking to another snowwoman. He turns to face the snowwoman and says Hello. She turns to look at him then looks back at her friend, and continues the conversation. The snowman s face turns red, and he hangs his head down. Lab 1: Introduction 14

15 Lab 2: Sequential & Parallel Execution Do in order Open the file lab2.a2w. There are three characters in the scene: Alice, the rabbit, and the cat. We would like to get the cat to turn towards the rabbit and the rabbit to turn towards the cat. The rabbit then says Nice day isn t it? Alice then turns towards them and says Hello there. The cat and the rabbit turn to her. She then walks towards them and says I m Alice. The above example seems like a fairly simple one to implement. Before we do that, let us draw up a flowchart of our scene. Lab 2: Sequential & Parallel Execution 15

16 Start Cat turns towards the rabbit Rabbit turns towards the cat Rabbit says Nice day, isn t it? Alice turns towards them Alice says Hello there Cat turns towards Alice Rabbit turns towards Alice Alice walks to the cat and rabbit Alice says I m Alice Stop Lab 2: Sequential & Parallel Execution 16

17 As you can see from the flowchart, each of these instructions needs to be done in order, i.e. one instruction is completed, before the following one begins. We can tell Alice to do these instructions in order by using the do in order control statement. To do this, drag the Do in order statement to the editor area. To place instructions in the Do in order block, simply drag the instructions into the block as shown below. Lab 2: Sequential & Parallel Execution 17

18 Exercise 1 Using the flowchart above, fill the rest of the instructions in the Do in order block. This should not take more than 5 minutes. Do together There are many cases when instructions need to be done together, rather than one after the other. For instance, instead of the cat turning to face the rabbit then the rabbit turning to face the cat, it would be more meaningful if they both turn to each other at the same time. Let us modify the previous flowchart to reflect changes made to actions that must be done together. Lab 2: Sequential & Parallel Execution 18

19 Start Cat turns towards the rabbit Rabbit turns towards the cat Rabbit says Nice day, isn t it? Alice turns towards them Alice says Hello there Cat turns towards Alice Rabbit turns towards Alice Alice walks to the cat and rabbit Alice says I m Alice Stop Now the story makes more sense. Let us program the changes into our scene. To add a do together control statement, drag it inside the do in order block as shown below. Lab 2: Sequential & Parallel Execution 19

20 The first two instructions we want done together are the cat turning to the rabbit and vice versa. Drag them both from the do in order block into the do together block. Lab 2: Sequential & Parallel Execution 20

21 Press play to see the difference. Exercise 2 Complete the flowchart shown above by adding two more do together blocks to the scene. Further nesting We can have as many levels of do together and do in order blocks nested in each other as we need. Let us make Alice s walking more realistic. Instead of her whole body moving at once, we can program it so that her right leg moves first, then her left leg, and so on. Let us modify the flowchart accordingly. Lab 2: Sequential & Parallel Execution 21

22 Start Cat turns towards the rabbit Rabbit turns towards the cat Rabbit says Nice day, isn t it? Alice turns towards them Alice says Hello there Cat turns towards Alice Rabbit turns towards Alice Alice moves right foot forward Alice moves left foot forward Alice moves right foot forward Alice says I m Alice Alice moves left foot forward Stop To achieve this, we need to do the movements sequentially, but at the same time execute Alice s talk method. This can be done by adding a do in order block inside the do together block. First, delete the existing Alice move method. Your instructions list should look like this: Lab 2: Sequential & Parallel Execution 22

23 Now, add the do in order block into the last do together block in the scene. Lab 2: Sequential & Parallel Execution 23

24 Exercise 3 Complete the scene using the flowchart above. Your program should now look like this: Lab 2: Sequential & Parallel Execution 24

25 You may have noticed that this instruction set causes Alice s legs to move on their own, without the rest of the body!! That is true. This is a mistake or a bug in our code. Exercise 4 Modify the flowchart and the program so that Alice s legs do not walk on their own! Hint 1: Use methods to move all of Alice along with her legs. Hint 2: Use the turn method for the legs instead of the move method. Hint 3: Use the duration parameter in the methods you call to time the actions together. Remember that the default time for each action is 1 second. Exercise 5 Create a new world using the grass template. Add a hawk to the scene. Add instructions to the scene so that the hawk flaps its wings twice while flying forward, and then does a complete rotation in the sky. Lab 2: Sequential & Parallel Execution 25

26 Lab 3: Branching & Looping Exercise 1: Review Open the file lab3.a2w. The scene contains two ice skaters and a bunny. The scene starts with iceskater turning towards iceskater2. IceSkater2 then turns towards iceskater. Then, iceskater2 and iceskater both move to pose2. At the same time, the bunny moves up by 0.5 meters. Make the bunny hopping more realistically by turning the bunny s legs. IceSkater and iceskater2 then move to pose3, while the bunny moves downwards. Similarly, adjust the bunny s legs so that they are back at their original position. This exercise should take about 10 minutes. Conditional execution Sometimes, you may want an instruction to be executed only if a condition is true. For instance, a pedestrian will cross the road only if the pedestrian light says WALK. Otherwise, the pedestrian waits. This conditional execution can be performed by the if/else control structure. This structure checks a specified condition, and makes a decision about whether or not a section of the code will be run. Let us take a specific example: A hare and a husky stand next to each other. If the hare is to the left of the husky, the hare says I am at your left. Otherwise, it says I am not at your left. This is what the flowchart may look like: True Is the Hare to the left of the Husky? False Hare says I am at your left Hare says I am not at your left Notice that the answer to the condition must be either true or false. frue and false are known as Boolean values (after the great mathematician George Boole). All conditions in the if/else structure must evaluate to a Boolean value. Let us implement this in Alice. Open the file lab3if1.a2w. Lab 3: Branching & Looping 26

27 The first thing we need to do is to drag the if/else structure into the method editor. Notice that Alice gives you a choice for the initial condition between true and false. Select true. Now we need to change the condition to the one we used in our flowchart. To find out whether the hare is to the left of the husky, we can use the hare object s built-in functions. Click the hare in the object tree window or in the world window. From the functions tab in the details window, drag the Hare s function is to the left of into if condition, replacing true. Lab 3: Branching & Looping 27

28 Exercise 2 Complete the above program so that it performs the instructions in the flowchart. In the world window, move the husky or hare around (using your mouse) and run the program to test your code. Relational Operators In the previous example, a built-in function was used to check a condition in our world. However, it is difficult to provide built-in functions for everything that we may need in our code. Therefore, we can use relational operators to write our own conditions. A relational operator is one which asks a question about the relationship between two entities. The result of a relational operation is a Boolean value. Here is the list of relational operators: A==B Is A equal to B? A!=B Is A not equal to B? A>B Is A greater than B? A>=B Is A greater than or equal to B? A<B Is A less than B? A<=B Is A less than or equal to B? Lab 3: Branching & Looping 28

29 Let us try to apply relational operators in our current world. Delete the previous if/else construct, so that the method editor is empty. We now want the husky to scratch its ears for 2 seconds and wag its tail with turn scale 1 and duration scale 2 (in parallel) if the height of the hare is less than or equal to 2. Otherwise, the husky needs to walk a number of cycles equal to the hare s height. Drag a new if/else construct into the method editor window. To use relational operators, click object world in the object tree. Go to the functions of the world object. Underneath the heading math, you will notice the relational operators shown earlier. Drag the operator we need on top of the true tile next to the if/else statement. Select any numbers you like for a and b. For this example, we selected 2 and 2 respectively. If we keep the code as it is above, the if block will always be the one that is executed. This is because 2<=2 will always evaluate to true. Lab 3: Branching & Looping 29

30 Exercise 3 Complete the above code. Replace the 1 st 2 in the relational operation with the height of the hare then fill in the if and else blocks. Randomness The problem with the above code is obvious: What is the point of using conditional statements if the values we are comparing are fixed? This is where we can introduce randomness into our programs. We can set the size of the hare to a random size at the beginning of the program using the world function random. Start by dragging the hare method resize before the if/else block. Select 2 (or any other number) as the resizing factor. Now we need to set the resize factor to a random number. Keep in mind that while the hare s height and size are directly proportional, they are not the same thing. Lab 3: Branching & Looping 30

31 Select world in the object tree and navigate to the world object functions. Drag the function random number on top of the resize amount. Now we need to set restrictions so that the hare is not resized to a very large or very small value. This is why we need to set the minimum and maximum values for the random number to be generated. Select the more menu next to the random number function and set the minimum to 0.1 and the maximum to 1.5. Also make sure the intergeronly parameter is set to false. Lab 3: Branching & Looping 31

32 What the above code means is that the hare can be resized to a random number between 0.1*its original size and 1.5*its original size. When the integeronly parameter is set to false, it means that the random number generated can contain decimals. Run the movie a few times, and notice how the outcome has become unpredictable. Exercise 4 Open the file lab3rep.a2w. Get the robot to kick its left leg and at the same time point its cannon forward. The robot must return to its initial position each time. The robot needs to repeat this three times. The robot must also get smaller by 0.9 at every repetition. Repetition After the previous example, you are probably thinking that there has to be an easier way to repeat instructions without copying the same instructions over and over again. Well there is! Remove the redundant instructions so that your code looks like this: Lab 3: Branching & Looping 32

33 We shall now use a new control statement called a loop. Drag it to your editor s area. Lab 3: Branching & Looping 33

34 A menu shows up asking how many times you would like the loop to run. We need it to repeat 3 times. Select other and type 3 using the keypad. Lab 3: Branching & Looping 34

35 Now drag the code you want repeated into the loop block. Lab 3: Branching & Looping 35

36 Exercise 5 Change the loop so that it repeats forever (infinity). Place an if/else block inside the loop so that the movement and resizing only happens when the robot s height is greater than 1. While loops Notice now that the robot stops moving and shrinking once the height is 1 or less. The problem with this program is that while the robot stops shrinking at the required size, the program remains stuck in the loop indefinitely. We need our program to break the loop once the loop condition becomes false. This can be done by using a while control statement, instead of using loops and if/else statements like we did above. A While statement keeps repeating the code inside its block until the while condition becomes false. When the condition is false, the program continues to execute the code that comes after the while block. The following is a flowchart of how while statements work. Lab 3: Branching & Looping 36

37 Is condition satisfied? True Do certain actions False Let us modify our previous example, so that it uses a while loop instead of loops and if constructs. Drag the while control statement to the editor s area. Lab 3: Branching & Looping 37

38 Similar to if/else statements, Alice provides you with a menu showing the Boolean values true and false. This is because both while and if/else statements use conditions which must evaluate to a Boolean value. Select true from the menu, then drag the part of the code you want to be repeated into the while block. Lab 3: Branching & Looping 38

39 Now we just need to change the condition in the while statement. You can simply drag the conditional operation we created previously for the if construct on to the condition title of the while block. Now delete the parts of the code you don t need any more. Lab 3: Branching & Looping 39

40 Exercise 6 Add a fighter object to your world. The fighter should be hovering on top of the robot as shown in the screenshot below. Lab 3: Branching & Looping 40

41 While the robot is changing size and moving, the fighter should move downwards by half its distance above the robot. This should only be done once and only if the fighter is larger than the robot. Otherwise, the fighter should resize so that it is 1.5 times larger. Use a loop to repeat the if/else block twice. Now try replacing the loop and the if/else statement with a while statement. Lab 3: Branching & Looping 41

42 Lab 4: Lists Lists Open the file lab4lists.a2w. The world consists of three different cows making up a cow dance group. A world-level method called looktoright has been created. This method takes an object parameter named acow. The world also starts off playing a sound clip for the cows to dance to. Let us fill in the method looktoright. The first thing we need to do is turn the cow s head 0.2 revolution to the right. This is not as straightforward as it may seem. First, drag the cow.head s turn method into the looktoright method space. Set the method to turn right by 0.2 revolutions. The above code turns the head of the 1 st cow only, not the head of the parameter acow. We can change that using a function called part named. Take a look at the cow functions (not cow.neck.head). At the very bottom you will see the part named function. Drag that over cow.neck.head in the turn method. Lab 4: Lists 42

43 Now we need to enter the specific name of the cow part we want to turn. Looking at the object tree, we know that the part is neck.head. Note that Alice is case sensitive, so be sure to spell the names correctly. Your method should now look like this: Lab 4: Lists 43

44 The final step would be to use the acow parameter rather than the cow object. Drag the acow parameter from next to the method name to replace cow in the turn method call. Lab 4: Lists 44

45 Exercise 4 Complete the world.looktoright method so that the cow s head is back to its original position. (Hint: right-click the turn method and select make a copy. You can then make the required changes.) Exercise 5 Get the cows to all turn their heads together at the beginning of the song. Since all the objects we are moving are of the same type and use the same methods and body parts, we can simply add them all to a list. To do this, click on world in the object tree, then select create new variable in the world s properties. Name the variable listofcows. Choose the type to be Object, select the make a List checkbox, and then add the three cows as items in the list. Lab 4: Lists 45

46 We now created a variable, containing all three cows. Let us see how we can use this structure. Delete the code you added previously which called the looktoright method. The two main statements we shall use with lists are named For all in order and For all together. The 1 st statement performs operations on lists sequentially, i.e. one list item at a time. The 2 nd statement performs operations on all list items simultaneously. Drag the For all together statement underneath the play sound method call. When prompted, select the listofcows list that was just created. Lab 4: Lists 46

47 Now drag the method looktoright into the For all together block. Select item_from_listofcows as the method parameter. Try running your program now. Lab 4: Lists 47

48 Exercise 6 Modify your program so that the cow s turn their heads one at a time rather than all together. Exercise 7 Complete the dance! Start off with the head turn followed by a synchronized kick (all together). At the end of it, each cow should moo individually. Sound (optional) Nobody debates that, with very few exceptions, the use of sound is necessary in any good animation, video, or game. Open the file lab4.a2w. The world contains three animals, and the first method calls a class-level method: horse.neigh. Playing the animation and viewing the code for the horse.neigh method will show you that all it does is turn the mouth of the horse downwards then upwards. What is lacking here is the actual sound of the horse neighing. To add a sound file to the horse, go to the horse s properties, and expand the sound section as shown below. We now have two options: we can either import a sound file, or record one ourselves. Click on import sound. Lab 4: Lists 48

49 Make sure you have downloaded the file horse-neigh1.wav. Import that file into the world. To play the sound file, go to the horse methods and drag the method play sound to horse.neigh. Select the sound file we just imported from the list of sounds shown. Now try running the scene. Lab 4: Lists 49

50 Exercise 8 Create a class-level method for the cow class called mooing. In this method, the cow should turn its lower mouth in the same way the horse does. Notice that the cow class already has a built-in moo sound file so there is no need to import one. Call this method from the world.my first method. Exercise 9 Create a similar class-level method called cluckcluck for the chicken class. Notice that a chicken sound is available, but it does not belong to the chicken class. It belongs to the world object. Fix the durations so that the chicken sound does not go on after the chicken s mouth movement is complete. Call this method from the world.my first method. Exercise 10 Doesn t it seem a little redundant to do the same thing for all three classes? Create a new world-level method named introduction. This method takes as parameters the animal part that needs to be turned (mouth/lower mouth) and the sound the animal needs to make. Call this method three times, so that the horse, cow and chicken all get the chance to introduce themselves in their own languages. Lab 4: Lists 50

51 Lab 5: Event Handling Interactive programming & event handling So far, we have focused on developing movie-style animations in Alice. These programs are not interactive. In this lab, you will learn how to write interactive programs in Alice, where the users can interact with the objects in an Alice world using mouse and keyboard. Control of flow Control of flow refers to the control on the order of actions in a program. Noninteractive programs are computer-centric, where the order of actions is predetermined by the programmer. On the other hand, interactive programs are user-centric, where the order of actions is determined at runtime based on user interactions such as mouse clicks and key presses on the keyboard. Events Every time the user provides some sort of input, through a mouse click or key press for instance, we say an event is generated. Event handing methods An event may trigger a response or move objects in the scene to positions that lead to some condition (such as a collision) that triggers a response. A response to an event can be an action or a sequence of actions that needs to be carried out. Responding methods are written to perform the intended responses, and the events are linked to the indented responding methods. Such responding methods are known as event handling methods. Example 1: Ice Skater Open the file Lab5-Example1.a2w. The World contained in this file is adapted from the solution of Exercise 1 from Lab 1, which can be found on page 4 of this lab manual. As shown in the Figure 1 below, the World consists of a lake and an IceSkater object. The IceSkater has the following four user-defined methods: (i) prepare to skate, which sets the IceSkater to an initial pose; (ii) skate, which accepts the number of steps the IceSkater has to skate through an argument variable (parameter) named howmanysteps and makes the IceSkater skate for howmanysteps steps; (iii) skate backwards, which accepts the number of steps the IceSkater should skate backwards through an argument variable named howmanysteps and makes the IceSkate skate backwards for howmanysteps steps; and Lab 5: Event Handling 51

52 (iv) jump, which makes the IceSkater jump. Figure 1. Objects, methods, and Events editor In this example and the following two exercises (Exercises 1 2), we want to make the IceSkater respond to a number of key presses on the keyboard. Note that the Events editor in Figure 1 is empty. The Events editor is where the event handling methods are linked to the events. When an event is generated, it triggers the linked event handling method as a response. Lab 5: Event Handling 52

53 Figure 2. Types of events To create an event in Alice, you first have to press the create new event button close to the top-left corner of the Event editor, which then shows a list containing the types of events you can create (see Figure 2). When the world starts, we want the IceSkater to prepare for skating, which can be achieved by the userdefined method prepare to skate. Therefore, here the start of the world is generating an event, which should trigger a response carried out by the event handling method prepare to skate. After pressing the create new event button, choose When the world starts from the list. This will introduce a When the world starts tile in the Events editor. Next, as shown in Figure 3, drag the IceSkater s prepare to skate method onto Nothing in this tile. Now the start of the world event is linked to the event handling method prepare to skate. Press the Play button to see what the IceSkater does. Lab 5: Event Handling 53

54 Figure 3. Linking an event handling method to an event Next, we want the IceSkater to skate one step forward when the Up arrow key is pressed on the keyboard. After pressing the create new event button, choose When a key is typed from the list. This will introduce a When a key is typed tile at the end of the instruction list in the Events editor. Choose Up in place of any key in this tile as shown in Figure 4. Then drag the IceSkater s skate method onto Nothing in this tile and choose 1 for value of the argument howmanysteps. Figure 4. Choosing the Up arrow key Now, the instructions in your Events editor should look as shown in Figure 5. Lab 5: Event Handling 54

55 Figure 5. After linking the event handling method skate with the Up arrow key press event Press the Play button and then the Up arrow key on the keyboard a few times to see what the IceSkater does. Observe that nothing happens while the Up arrow key is in a pressed state. The IceSkater skates for 1 step when the Up arrow key is released after being pressed. Now, we want the IceSkater to keep on skating forward while the Up arrow key is in a pressed state and stop skating when the Up arrow key is released after being pressed. To achieve this, delete the last tile we created in the Events editor and reintroduce a When a key is typed tile. Then right-click on this tile, go to change to, and choose to click on While a key is pressed. This will change the When a key is typed tile to a While a key is pressed tile. Figure 6. Introducing a While a key is pressed tile Next, choose Up in place of any key in the newly introduced While a key is pressed tile. As shown in Figure 7, this tile allows you to mention what action should take place at the start of a key press (in the Begin part), while the key is in a pressed state (in the During part), and when the key is released (in the End part). Figure 7. After introducing the While a key is pressed tile Lab 5: Event Handling 55

56 Now, drag the IceSkater s skate method onto <None> in the During part of this tile and choose 1 for value of the argument howmanysteps. Also, drag the IceSkater s prepare to skate method onto <None> in the Begin part and onto <None> in the End part of this tile. This allows the IceSkater to start skating from her initial pose when the Up arrow key is pressed and she should again return to her initial pose when the Up arrow key is released. At this point, the instructions in your Events editor should look as shown in Figure 8. Figure 8. After introducing the While a key is pressed tile Once again, press the Play button and then the Up arrow key to see what the IceSkater does. Exercise 1 Extend the world from Example 1 to handle the following events: (i) While the Down arrow key is pressed, make the IceStaker skate backwards. Use the IceSkater s stake backwards method as the event handling method. (ii) While the Left and Right arrow keys are pressed, make the IceSkater turn left and right, respectively. Use the IceSkater s built-in turn method as the event handling method. (iii) When the Space bar is pressed, make the IceSkater jump. Use the IceSkater s jump method as the event handling method. Exercise 2 Note that in the worlds resulting from Example 1 and Exercise 1, the IceSkater can go off the screen while skating. Can you think of a way to fix this problem? There are two easy solutions one is to move the camera and the other is to change camera orientation such that the IceSkater is visible. Hints: Make use of either Let the mouse move the camera or Let the mouse orient the camera event. These events have built-in event handlers; i.e. you will not need to write an event handling method or use any built-in method to carry out the responses for these events. Lab 5: Event Handling 56

57 Example 2: Mummy Catches Pharaoh Open the file Lab5-Example2.a2w. As shown in the Figure 9 below, the world consists of a pyramid, a sphinx, an ourownpharaoh, a mummy, and a 3D Text object. Figure 9. Added objects ourownpharaoh has the following two user-defined methods (Figure 10(a)): (i) takesteps, which accepts the number of steps ourownpharaoh has to take and the duration of each step in argument variables named numberofsteps and timeperstep, respectively, and the method makes ourownpharaoh take numberofsteps steps consuming timeperstep seconds per step; (ii) getscared, which makes ourownpharaoh scream and fall on the ground to show him getting unconscious. Next, as shown in Figure 10(b), the mummy has the following two user-defined methods: (i) takesteps, which acts in the same way as ourownpharaoh s takesteps method, but this method is defined for the mummy object; (ii) resetpose, which sets the mummy to its initial pose. Finally, as shown in Figure 10(c), the 3D Text has its text property set to Mummy got the pharaoh!, font property set to Agency FB Bold, isshowing property set to false, and a particular color is chosen for the text. Lab 5: Event Handling 57

58 (a) (b) (c) Figure 10. User-defined methods and set properties In this example and the following four exercises (Exercises 3 6), we want the mummy to catch ourownpharaoh. The user will be able to control mummy s movement using the keyboard and ourownpharaoh will wander around randomly as if he is scared and trying avoid being caught by the mummy. If the mummy catches ourownpharaoh, ourownpharaoh will scream and get unconscious. First, create a world-level method named play. Keep its body empty for now. We want this play method to be the event handling method that should be called as long as ourownpharaoh does not get caught by the mummy. To perform this, let us first create a world-level Boolean variable named ispharaohfree and set its initial value to be true. This Boolean variable should be true as long as ourownpharaoh does not get caught by the mummy. Now, introduce a While something is true tile in the Events editor from the list you can access by pressing the create new event button. Drag the ispharaphfree Boolean variable onto <None> of this While something is true tile as shown in Figure 11. Also, drag the play method onto Nothing in the During part of this tile. Lab 5: Event Handling 58

59 Figure 11. Using a While something is true event Now, your Events editor should look as shown in Figure 12. Figure 12. The While something is true event Exercise 3 Extend the world from Example 2 to handle the following events: (i) While the Up arrow key is pressed, make the mummy walk forward. Anytime the Up arrow key is pressed, the mummy should start walking from its initial pose and anytime the Up arrow key is released after being pressed, the mummy should return to its initial pose. Use mummy s takesteps and resetpose methods as event handling methods. (ii) While the Left and Right arrow keys are pressed, make the mummy turn left and right, respectively. Use the mummy s built-in turn method as the event handling method. (iii) Let the mouse move the camera. Lab 5: Event Handling 59

60 Exercise 4 Create and define a method named randommove for ourownpharaoh that will allow him to randomly wander around. More specifically, define the method randommove as follows: (i) It should accept two arguments named directiontoturn and revolutionstoturn, both of type Number. (ii) If the value of directiontoturn is less than 0.5, make ourownpharaoh turn left; otherwise turn right. The turn should be for revolutionstoturn revolutions. (iii) Make ourownpharaoh walk forward using its takesteps method. Exercise 5 Create and define a world-level method named didmummycatchpharaoh that will check if the mummy could catch ourownpharaph and carry out an appropriate sequence of actions, if true. In the didmummycatchpharaoh method, check if ourownpharaoh is within less than 1 meter of any of mummy s forearms. If yes, then execute the following instructions: (i) ourownpharaoh should get scared. Make use of ourownpharaoh s user-defined method getscared. (ii) The following actions should take place simultaneously: the 3D Text should turn to face the camera and show up; the mummy should raise both of its hands out of joy. (iii) Set the world-level Boolean variable ispharaohfree to false. Exercise 6 Create two world-level variables named turndirection and turnrevolutions, both of type Number. Now, define the previously created world-level play method, which will contain the main body of the program. The play method should: (i) assign two randomly generated values to the variables, turndirection and turnrevolutions; (ii) make ourownpharaoh make a random walking movement (make use its randommove method using turndirection and turnrevolutions as arguments); and (iii) check if the mummy could catch ourownpharaoh (make use of the didmummycatchpharaoh method). Other types of events Other than what you have seen in the examples and exercises above, Alice 2.2 allows us to use four other types of events, which are When the mouse is clicked on something, When a variable changes, Let the mouse move <objects>, and Let the arrow keys move the <subject>. The last two of these four types of events have built-in event handlers. The next three exercises (Exercises 7 9) will involve the use of these types of events. Lab 5: Event Handling 60

61 Exercise 7 Open Lab5-Exercise7.a2w. The world contained in this file is the solution to Exercise 7 from Lab 4, which can be found on page 47 of this lab manual. Now, extend this world to carry out the following actions: (i) Allow the user to move each cow individually using the mouse. Make use of the world-level list variable listofcows. (ii) Allow the user to move the camera using the arrow keys on the keyboard. Exercise 8 Extend the world resulting from Exercise 7 so that if the user clicks one of the cows, the cow that has been clicked should swish its tail. Make use of the tailswish method that accepts two parameters, times and speed, both of type Number. The times parameter represents the number of times the cow should swish its tail and the speed parameter represents the speed at which it should swish its tail. Exercise 9 Modify and extend the world resulting from Exercise 8 as follows: (i) Add a strawbale object from the Farm gallery. Resize (not during runtime) the added strawbale object to be twice as big compared to its original size. (ii) Allow the user to move each cow as well as the strawbale individually using the mouse. (iii) Create and define a world-level method named walktowardsbale such that each of the three cows walks towards the strawbale if it is more than one meter away from it, for a random number of steps, at a random speed, at the same time. Make use of the walktowards method. (iv) Create a world-level variable named distance of type Number and initialize it to 0. (v) Delete all the existing instructions from world.my first method and redefine it to contain an infinite While loop, within which it assigns the distance between the strawbale and the camera to the previously created world-level variable distance. (vi) Create an event that triggers the walktowardsbale method as a response to change in the worldlevel variable distance. Now, press the Play button and move the strawbale around using the mouse to see what the cows do. Lab 5: Event Handling 61

62 Lab 6: Object Oriented Programming During the last series of Alice labs, you probably noticed that the programs can easily become long and complicated even if they only implement a few seconds of animation! The longer a program becomes, the more difficult it becomes to debug and modify, not to mention understanding it. This is why a paradigm known as object-oriented programming (OOP) is commonly used. OOP allows large programs to be broken down into smaller, more manageable pieces. The main components of OOP are classes, objects and methods. Classes In Alice, all of the types of models that can be added into a world are known as classes, such as the class BeachChair below Lab 6: Object Oriented Programming 62

63 Objects Once an instance of a class is added to the world, it is known as an object. Objects of the same class share the same methods and properties. However, each object is unique. Objects of the same class have different names and can have different values for their properties. The screenshot above shows two instances (objects) of the Camel class. However, each Camel object has a different name, size and color. Exercise 1 Recreate the world shown above. Notice that the camel names are camelo and camely and that camely has red ears. Methods A method is a sequence of instructions that can be called when needed. In previous tutorials, we used many of the methods that were built into Alice objects, such as moving, turning, and making a skater skate. These built-in methods can be grouped into our own methods, making programs easier to read and debug, and pieces of code easier to reuse and modify. There are two types of methods: world-level and class-level. Lab 6: Object Oriented Programming 63

64 World-level methods are ones which give instructions to more than one object. For instance, a world method called makeconversation, could ask the skater and snowman to discuss the weather among themselves. Class-level methods only give instructions to a single object. For instance, we may write a skate method for the iceskater and a hop method for the bunny. The next exercise will explain how to create world-level methods in Alice. Exercise 2 Click on File->New World. In the tutorial tab, select tutorial 2 and follow its steps. World-level methods Open file lab6egypt.a2w. The program is broken down into two world-level methods. First, the mummy and the pharaoh are oblivious to one another. They then notice each other, and the pharaoh runs away! Take a minute to look at the code before we continue. The program is broken down as follows: Program noticeeachother runaway Let us add another world-level method called getscared, between noticeeachother and runaway. Start by clicking the world object in the object tree. Then in the method list, select create new method. Lab 6: Object Oriented Programming 64

65 In the new method dialog box, type getscared. In this method, we want the camera to focus on the mummy, then show him/her scared. The same should then happen to the pharaoh. First, let us add the getscared method to the main program. Go to the my first method editor and drag the getscared method between noticeeachother and runaway. Lab 6: Object Oriented Programming 65

66 Now let s go back to creating the getscared method. We can control where the camera is focused at using the camera s methods. Click the camera object, and then drag the method set point of view to to the body of getscared method in the method editor area. The camera point of view should be set to the mummy s head. Lab 6: Object Oriented Programming 66

67 Run the program to see what effect this has. After the camera is set to show the pharaoh more closely, we can now show how scared the pharaoh is. Exercise 3 Let s show how scared the pharaoh is! Get the pharaoh s beard and nose to grow by 1.2, and at the same time, get his hat to spin 1 full revolution. This should happen while the pharaoh yells Aaaaah! Class-level methods It would be much neater if all of the code we just added for the pharaoh was in its own method. Since these instructions are specific to the pharaoh, we can create a class-level method. Click pharaoh from the object tree, and then select create new method from the methods list. Lab 6: Object Oriented Programming 67

68 Name the method getscared. To copy the code from the world.getscared method, drag the entire do together block that we need into the clipboard on the top-right corner of the Alice interface. Lab 6: Object Oriented Programming 68

69 Now, delete the do together block and replace it with a call to our new method, pharaoh.getscared. Lab 6: Object Oriented Programming 69

70 Go back to the pharaoh.getscared method and drag the contents of the clipboard into the editor s area. Lab 6: Object Oriented Programming 70

71 Now our pharaoh.getscared method is complete! Exercise 4 In the world.getscared method, append instructions to set the camera point of view to the pharaoh s head. After that, implement and call a getscared method for the mummy where his/her head grows by a factor of 1.2 then shrinks by a factor of 0.83 (1/1.2). At the same time, the mummy yells Oooooh! Lab 6: Object Oriented Programming 71

72 Dummy objects (optional) The world.getscared method should now look like this: Now we need to shift the camera s perspective back to the original view. Since there are no objects where the camera originally was, we cannot move the camera back to that perspective. For this reason, Alice allows you to place dummy objects where we want to move the camera to. To add a dummy object, click on the green ADD OBJECTS button. Click on the more controls button. Lab 6: Object Oriented Programming 72

73 Now click on the drop dummy at camera button. This places a dummy object at the camera s original position so that we can always go back to it. Select the green DONE button. You will now notice a new folder in the object tree named Dummy Objects. Expanding Dummy Objects shows dummy, the dummy object we just created. Click on camera in the object tree, and set its point of view to dummy. Lab 6: Object Oriented Programming 73

74 Method Parameters Method parameters (also called arguments) allow you to send information to methods. Most of the built-in methods you used so far required parameters. For instance, the turn method requires two parameters: the direction and the amount of turning. We can also add parameters to the methods we create. Let us take a look at the world.runaway method. Lab 6: Object Oriented Programming 74

75 The code looks very complicated and long. One way we could restructure it is by creating a class-level method for the pharaoh that instructs him to take one step forward. Exercise 5 Move the large do together loop (using the clipboard) into a new class-level method for the pharaoh. Name the method takesteps. Call takesteps from inside the loop in the world.runaway method. Now doesn t that look much better? Let us further improve the takesteps method so that the number of steps is a parameter. From the pharaoh.takesteps method, select the create new parameter button. As you can see from the dialog box, parameters can have numerous types. Obviously, the type we need is Number. Set the name of the parameter as numberofsteps. Now we want to repeat the code in the method a numberofsteps times. Create a loop structure, and drag the large do together block into it. Lab 6: Object Oriented Programming 75

76 To repeat the loop numberofsteps times, drag the parameter numberofsteps to set the loop repetition times. Lab 6: Object Oriented Programming 76

77 We can now remove the loop from the world.runaway method. Set the numberofsteps to 2. Exercise 6 Add another parameter to the pharaoh.takesteps method. Name the parameter timeperstep. The amount of time each of the steps should take is timeperstep. Don t forget to set the duration of the individual limb movement using expressions and maths. Lab 6: Object Oriented Programming 77

Alice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution

Alice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution Alice Mathematical Expressions, Conditional Statements, Control Structures Coverage Arithmetic Expressions Built-in Functions Conditional Execution If/Then Statements Control Structures Loops 1 Functions

More information

Repetition everywhere comparing while in a method and as an event. Comparison

Repetition everywhere comparing while in a method and as an event. Comparison Repetition everywhere comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011 Comparison This tutorial will explain the difference between using while in a

More information

Variables and Functions Chapter 3

Variables and Functions Chapter 3 Variables and Functions Chapter 3 3-1 Variables Named storage location in computer s memory Programs may need to store data when running o Stored in a variable Types of data that can be stored o Local

More information

Class-level Methods. Chapter 6 part 1

Class-level Methods. Chapter 6 part 1 Class-level Methods Chapter 6 part 1 Classes and Objects Classes o In Alice, classes are predefined as 3D models Objects o An object is an instance of a class Class: Frog (Uppercase first letter) Objects:

More information

Skater World: Part Three

Skater World: Part Three Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009 1 Overview The story continues: We will change the camera view during animation. Also,

More information

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

Telling a Story Visually. Copyright 2012, Oracle. All rights reserved. What Will I Learn? Objectives In this lesson, you will learn how to: Compare and define an animation and a scenario Demonstrate how to use the four problem solving steps to storyboard your animation Use

More information

Tutorial00. Jumping down the rabbit hole

Tutorial00. Jumping down the rabbit hole Tutorial00 Jumping down the rabbit hole This is your quick introduction into the world of ALICE. ALICE program provides us with an interface that allows the user to create 3D animation and write computer

More information

Name Introduction to Computer Science. 1. A sequence of instructions that tell the computer what to do is known as a?

Name Introduction to Computer Science. 1. A sequence of instructions that tell the computer what to do is known as a? Name Introduction to Computer Science 1. A sequence of instructions that tell the computer what to do is known as a? a. help screen b. mouse click c. computer program d. keystroke 2. Actions to be performed

More information

Exploring Alice and Object-Oriented Programming

Exploring Alice and Object-Oriented Programming Exploring Alice and Object-Oriented Programming PROJECT CASE PERSPECTIVE Dr. Carole Dodgson needs your help. She would like to use a sample virtual world to demonstrate some fundamental concepts of computer

More information

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010 Plotting Points By Francine Wolfe Professor Susan Rodger Duke University June 2010 Description This tutorial will show you how to create a game where the player has to plot points on a graph. The method

More information

potions. The troll doubles in size.

potions. The troll doubles in size. Tutorial 3: Use Procedures and Arguments, Add Rotation and Randomization Overview In this tutorial, you will practice using procedures and arguments to create an animation. You will practice rotating an

More information

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

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Getting Started with Java Using Alice Develop a Complete Animation 1 Copyright 2013, Oracle and/or its affiliates. All rights Objectives This lesson covers the following objectives: Use functional decomposition

More information

An object in 3D space

An object in 3D space An object in 3D space An object's viewpoint Every Alice object has a viewpoint. The viewpoint of an object is determined by: The position of the object in 3D space. The orientation of the object relative

More information

Chapter 0. Getting Started. Objectives

Chapter 0. Getting Started. Objectives Chapter 0 Getting Started Objectives Install the Java editor Install the Alice environment Setup the Java editor to work with the Alice environment Explain the purpose of Alice Setup an Alice scene Installing

More information

SCRATCH MODULE 3: NUMBER CONVERSIONS

SCRATCH MODULE 3: NUMBER CONVERSIONS SCRATCH MODULE 3: NUMBER CONVERSIONS INTRODUCTION The purpose of this module is to experiment with user interactions, error checking input, and number conversion algorithms in Scratch. We will be exploring

More information

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

Anjuli Kannan. Google Earth Driving Simulators (3:00-7:00) 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

More information

Choose the best answer from each of the following; answer A for True, B for False for any T/F questions.

Choose the best answer from each of the following; answer A for True, B for False for any T/F questions. Alice Quiz: Chapters 1-3 Choose the best answer from each of the following; answer A for True, B for False for any T/F questions. 1) According to the Alice text, learning to program makes you a computer

More information

Adobe Flash CS3 Reference Flash CS3 Application Window

Adobe Flash CS3 Reference Flash CS3 Application Window Adobe Flash CS3 Reference Flash CS3 Application Window When you load up Flash CS3 and choose to create a new Flash document, the application window should look something like the screenshot below. Layers

More information

DOING MORE WITH WORD: MICROSOFT OFFICE 2013

DOING MORE WITH WORD: MICROSOFT OFFICE 2013 DOING MORE WITH WORD: MICROSOFT OFFICE 2013 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT WORD PAGE 03 Viewing Toolbars Adding and Removing Buttons MORE TASKS IN MICROSOFT WORD

More information

The Alice Scene Editor

The Alice Scene Editor Facilitation Guide The Alice Scene Editor ( http://www.alice.org/resources/lessons/building-a-scene/ ) Summary This facilitation guide is intended to guide the instructor through the introduction of the

More information

DOING MORE WITH WORD: MICROSOFT OFFICE 2010

DOING MORE WITH WORD: MICROSOFT OFFICE 2010 DOING MORE WITH WORD: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT WORD PAGE 03 Viewing Toolbars Adding and Removing Buttons MORE TASKS IN MICROSOFT WORD

More information

Making Objects Move in Unison: Using Lists. Overview

Making Objects Move in Unison: Using Lists. Overview Making Objects Move in Unison: Using Lists By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008 Updated June 2014 by Yossra Hamid Edited for Alice 3 use by Anh Trinh July 2016 Overview

More information

Making Objects Move in Unison: Using Lists

Making Objects Move in Unison: Using Lists Making Objects Move in Unison: Using Lists By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008 Updated June 2014 by Yossra Hamid Edited for Alice 3 use by Anh Trinh July 2016 Overview

More information

the NXT-G programming environment

the NXT-G programming environment 2 the NXT-G programming environment This chapter takes a close look at the NXT-G programming environment and presents a few simple programs. The NXT-G programming environment is fairly complex, with lots

More information

This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step.

This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step. This Tutorial is for Word 2007 but 2003 instructions are included in [brackets] after of each step. Table of Contents Just so you know: Things You Can t Do with Word... 1 Get Organized... 1 Create the

More information

DOING MORE WITH WORD: MICROSOFT OFFICE 2007

DOING MORE WITH WORD: MICROSOFT OFFICE 2007 DOING MORE WITH WORD: MICROSOFT OFFICE 2007 GETTING STARTED PAGE 02 Prerequisites What You Will Learn USING MICROSOFT WORD PAGE 03 Viewing Toolbars Adding and Removing Buttons MORE TASKS IN MICROSOFT WORD

More information

Assignment 3: Optimizing solutions

Assignment 3: Optimizing solutions Assignment 3: Optimizing solutions Algorithmic Thinking and Structured Programming (in Greenfoot) c 2015 Renske Smetsers-Weeda & Sjaak Smetsers Licensed under the Creative Commons Attribution 4.0 license,

More information

StudioPrompter Tutorials. Prepare before you start the Tutorials. Opening and importing text files. Using the Control Bar. Using Dual Monitors

StudioPrompter Tutorials. Prepare before you start the Tutorials. Opening and importing text files. Using the Control Bar. Using Dual Monitors StudioPrompter Tutorials Prepare before you start the Tutorials Opening and importing text files Using the Control Bar Using Dual Monitors Using Speed Controls Using Alternate Files Using Text Markers

More information

Alice: A Free 3D Animation World for Teaching Programming

Alice: A Free 3D Animation World for Teaching Programming Alice: A Free 3D Animation World for Teaching Programming Barbara Ericson ericson@cc.gatech.edu Oct 2005 (Slightly adapted by Håkan Jonsson) Pick a World Playing the Movie! Click on the Examples tab "

More information

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

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

Walk Cycle with Symbols

Walk Cycle with Symbols Walk Cycle with Symbols STEP 1 Assuming you have your character all rigged and ready to go, double click on the character to get into the master symbol to see all the layers that make up all of the character

More information

Kids College Computer Game Programming Exploring Alice 3.X and Object-Oriented Programming

Kids College Computer Game Programming Exploring Alice 3.X and Object-Oriented Programming Kids College Computer Game Programming Exploring Alice 3.X and Object-Oriented Programming Alice is a programming language developed by Carnegie Mellon that makes it easy to write objectbased, event driven,

More information

Learning to Program: Part 1 Scene Setup and Star4ng Anima4on

Learning to Program: Part 1 Scene Setup and Star4ng Anima4on Learning to Program: Part 1 Scene Setup and Star4ng Anima4on by Ruthie Tucker and Jenna Hayes Under the direc4on of Professor Susan Rodger Duke University, July 2008 www.cs.duke.edu/csed/alice/aliceinschools

More information

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

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch Purpose: We will take a look at programming this week using a language called Scratch. Scratch is a programming language that was developed

More information

Duration 30 minutes Notes This tutorial was built using Alice

Duration 30 minutes Notes This tutorial was built using Alice Tutorial 1: Get Started with Alice 3 Overview In this tutorial, you will become familiar with the basic features of Alice 3. You will navigate and use basic features in both the Scene editor and Code editor.

More information

The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008

The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 The Essentials of Alice (Bunny) By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 This tutorial will teach you how to create a short animation in an Alice world. Follow

More information

IAT 445 Lab 10. Special Topics in Unity. Lanz Singbeil

IAT 445 Lab 10. Special Topics in Unity. Lanz Singbeil IAT 445 Lab 10 Special Topics in Unity Special Topics in Unity We ll be briefly going over the following concepts. They are covered in more detail in your Watkins textbook: Setting up Fog Effects and a

More information

Appendix A Reference: Built-in Methods

Appendix A Reference: Built-in Methods Appendix A Reference: Built-in Methods The Methods panel has three tabs so as to distinguish between procedural methods, functional methods, and methods related to that object's specific properties. Figure

More information

Methods & Classes in Alice

Methods & Classes in Alice Part A Creating Custom Methods for an Object Alice provides primitive methods with each class to allow the programmer to accomplish some basic tasks such as movement. Some classes also include custom methods

More information

How to draw and create shapes

How to draw and create shapes Adobe Flash Professional Guide How to draw and create shapes You can add artwork to your Adobe Flash Professional documents in two ways: You can import images or draw original artwork in Flash by using

More information

IT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008

IT Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008 IT 101 - Introduction to Programming for I.T. Midterm Exam #1 - Prof. Reed Spring 2008 What is your name?: (0 points) There are two sections: I. True/False..................... 20 points; ( 10 questions,

More information

Animate a Name Cards

Animate a Name Cards Animate a Name Cards Animate the letters of your name, initials, or favorite word. Animate Your Name 1 Set of 7 cards Animate a Name Cards Try these cards in any order: Color Clicker Spin Play a Sound

More information

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING

AN INTRODUCTION TO SCRATCH (2) PROGRAMMING AN INTRODUCTION TO SCRATCH (2) PROGRAMMING Document Version 2 (04/10/2014) INTRODUCTION SCRATCH is a visual programming environment and language. It was launched by the MIT Media Lab in 2007 in an effort

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

The first program: Little Crab

The first program: Little Crab Chapter 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,

More information

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013 GETTING STARTED PAGE 02 Prerequisites What You Will Learn MORE TASKS IN MICROSOFT EXCEL PAGE 03 Cutting, Copying, and Pasting Data Basic Formulas Filling Data

More information

Princess & Dragon Part 1: Objects in an Alice World

Princess & Dragon Part 1: Objects in an Alice World Princess & Dragon Part 1: Objects in an Alice World By Elizabeth Liang under the direc?on of Professor Susan Rodger Duke University May 2010 Updated June 2014 by Ellen Yuan Introduc)on Welcome to Alice!

More information

The Essentials of Alice

The Essentials of Alice The Essentials of Alice Mrs. Jayne Slease SBMS CTE Computer Science and Animation Credit to Duke Students under the direction of Professor Susan Rodger Duke University May 2009 This tutorial will teach

More information

Major Assignment: Pacman Game

Major Assignment: Pacman Game Major Assignment: Pacman Game 300580 Programming Fundamentals Week 10 Assignment The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.

More information

By Ruthie Tucker Under the direction of Professor Susan.

By Ruthie Tucker Under the direction of Professor Susan. Tutorial for Arrays and Lists By Ruthie Tucker Under the direction of Professor Susan Rodger, Duke University 2008 www.cs.duke.edu/csed/alice/aliceinschools Description This presentation will cover the

More information

Exit: These control how the object exits the slide. For example, with the Fade animation the object will simply fade away.

Exit: These control how the object exits the slide. For example, with the Fade animation the object will simply fade away. PowerPoint 2013 Animating Text and Objects Introduction In PowerPoint, you can animate text and objects such as clip art, shapes, and pictures. Animation or movement on the slide can be used to draw the

More information

Introduction to Alice. Computer Science for High School (CS4HS)

Introduction to Alice. Computer Science for High School (CS4HS) Introduction to Alice Computer Science for High School (CS4HS) Contents 1 Introduction 2 2 Installation 3 2.1 Basic Installation........................... 3 2.2 Advanced Installation........................

More information

Methods (part 2) Alice In Action, Ch 2

Methods (part 2) Alice In Action, Ch 2 CS 120 Lecture 03 Methods (part 2) Alice In Action, Ch 2 4 September 2012 Slides Credit: Joel Adams, Alice in Action Objectives Build class-level methods to elicit desirable behaviors from objects Reuse

More information

Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes

Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July 2013 Introduction! In this tutorial, we will set

More information

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface CHAPTER 1 Finding Your Way in the Inventor Interface COPYRIGHTED MATERIAL Understanding Inventor s interface behavior Opening existing files Creating new files Modifying the look and feel of Inventor Managing

More information

Events (Alice In Ac.on, Ch 6)

Events (Alice In Ac.on, Ch 6) CS 101 Lecture 26/27 Events (Alice In Ac.on, Ch 6) Slides Credit: Joel Adams, Alice in Action Objectives Programming to respond to events Create new events in Alice Create handler methods for Alice events

More information

Decision Structures. Chapter 4

Decision Structures. Chapter 4 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 when used o What decision structures are and when

More information

Animations involving numbers

Animations involving numbers 136 Chapter 8 Animations involving numbers 8.1 Model and view The examples of Chapter 6 all compute the next picture in the animation from the previous picture. This turns out to be a rather restrictive

More information

Recipes4Success. Animate Plant Growth. Share 4 - Animation

Recipes4Success. Animate Plant Growth. Share 4 - Animation Recipes4Success In this Recipe, you will create an animated science diagram of plant growth. You will learn how to add images, draw shapes, use the animation options, preview, and publish your project.

More information

Flash offers a way to simplify your work, using symbols. A symbol can be

Flash offers a way to simplify your work, using symbols. A symbol can be Chapter 7 Heavy Symbolism In This Chapter Exploring types of symbols Making symbols Creating instances Flash offers a way to simplify your work, using symbols. A symbol can be any object or combination

More information

using Arrays and Lists in an Alice world Prerequisites Everything World.OpeningScene Cinderella.end the chickens while they dance.

using Arrays and Lists in an Alice world Prerequisites Everything World.OpeningScene Cinderella.end the chickens while they dance. Tutorial for Arrays and Lists Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens on a farm Prerequisites Everything By Ruthie Tucker

More information

Animating Objects in Groups: Using Arrays and Lists

Animating Objects in Groups: Using Arrays and Lists Animating Objects in Groups: Using and By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008 Description This tutorial will cover the basics of using arrays and lists in an Alice world.

More information

Visualization Insider A Little Background Information

Visualization Insider A Little Background Information Visualization Insider A Little Background Information Visualization Insider 2 Creating Backgrounds for 3D Scenes Backgrounds are a critical part of just about every type of 3D scene. Although they are

More information

Introduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy

Introduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy Introduction to Unreal Engine Blueprints for Beginners By Chaven R Yenketswamy Introduction My first two tutorials covered creating and painting 3D objects for inclusion in your Unreal Project. In this

More information

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010 DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010 GETTING STARTED PAGE 02 Prerequisites What You Will Learn MORE TASKS IN MICROSOFT EXCEL PAGE 03 Cutting, Copying, and Pasting Data Filling Data Across Columns

More information

Section 5. Pictures. By the end of this Section you should be able to:

Section 5. Pictures. By the end of this Section you should be able to: Section 5 Pictures By the end of this Section you should be able to: Use the Clip Gallery Insert and Delete Pictures Import Pictures Move, Resize and Crop Pictures Add Borders and Colour Wrap Text around

More information

Scratch Lesson 2: Movies Made From Scratch Lesson Framework

Scratch Lesson 2: Movies Made From Scratch Lesson Framework Scratch Lesson 2: Movies Made From Scratch Lesson Framework Scratch makes it easy to program your own interactive stories, games, and animations and share your creations on the web. As you create and share

More information

Animating Objects in Groups: Using Arrays and Lists. By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008

Animating Objects in Groups: Using Arrays and Lists. By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008 Animating Objects in Groups: Using Arrays and Lists By Ruthie Tucker under the direction of Professor Susan Rodger Summer 2008 Description This tutorial will cover the basics of using arrays and lists

More information

INTRODUCTION TO LABVIEW

INTRODUCTION TO LABVIEW INTRODUCTION TO LABVIEW 2nd Year Microprocessors Laboratory 2012-2013 INTRODUCTION For the first afternoon in the lab you will learn to program using LabVIEW. This handout is designed to give you an introduction

More information

S3 Scratch Programming

S3 Scratch Programming LOREM ST LOUIS IPSUM DOLOR ST LOUIS SCHOOL S3 Computer Literacy S3 Scratch Programming Dominic Kwok CHAPTER 1 Scratch After studying this chapter, you will be able to create a simple Scratch program upload

More information

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

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional Meet the Cast Mitch A computer science student who loves to make cool programs, he s passionate about movies and art, too! Mitch is an all-around good guy. The Cosmic Defenders: Gobo, Fabu, and Pele The

More information

S A M P L E C H A P T E R

S A M P L E C H A P T E R SAMPLE CHAPTER Anyone Can Create an App by Wendy L. Wise Chapter 5 Copyright 2017 Manning Publications brief contents PART 1 YOUR VERY FIRST APP...1 1 Getting started 3 2 Building your first app 14 3 Your

More information

Microsoft Excel Level 2

Microsoft Excel Level 2 Microsoft Excel Level 2 Table of Contents Chapter 1 Working with Excel Templates... 5 What is a Template?... 5 I. Opening a Template... 5 II. Using a Template... 5 III. Creating a Template... 6 Chapter

More information

The Mathcad Workspace 7

The Mathcad Workspace 7 For information on system requirements and how to install Mathcad on your computer, refer to Chapter 1, Welcome to Mathcad. When you start Mathcad, you ll see a window like that shown in Figure 2-1. By

More information

Chapter 25 Design Tools

Chapter 25 Design Tools Chapter 25 Design Tools There are several tools in HCA that can make managing your home design a bit easier. This chapter describes these tools and includes: Using the Program Variable Inventory HCA Status

More information

The Institute for the Future of the Book presents. Sophie. Help. 24 June 2008 Sophie 1.0.3; build 31

The Institute for the Future of the Book presents. Sophie. Help. 24 June 2008 Sophie 1.0.3; build 31 The Institute for the Future of the Book presents Sophie Help 1 24 June 2008 Sophie 1.0.3; build 31 1. Contents Working with Sophie 4 Sophie s interface 4 Halos and HUDs 4 Flaps, tabs, and palettes 9 The

More information

Unit E Step-by-Step: Programming with Python

Unit E Step-by-Step: Programming with Python Unit E Step-by-Step: Programming with Python Computer Concepts 2016 ENHANCED EDITION 1 Unit Contents Section A: Hello World! Python Style Section B: The Wacky Word Game Section C: Build Your Own Calculator

More information

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

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved. Getting Started with Java Using Alice 1 Copyright 2013, Oracle and/or its affiliates. All rights Objectives This lesson covers the following objectives: Use the IF control structure to effect execution

More information

By Deborah Nelson Duke University Under the edirection ecto of Professor Susan Rodger July 13, 2008

By Deborah Nelson Duke University Under the edirection ecto of Professor Susan Rodger July 13, 2008 BDE tutorial By Deborah Nelson Duke University Under the edirection ecto of Professor Susan Rodger July 13, 2008 Loading the World Open a new world, with any template Save it in a directory that you can

More information

Introduction to MS Office Somy Kuriakose Principal Scientist, FRAD, CMFRI

Introduction to MS Office Somy Kuriakose Principal Scientist, FRAD, CMFRI Introduction to MS Office Somy Kuriakose Principal Scientist, FRAD, CMFRI Email: somycmfri@gmail.com 29 Word, Excel and Power Point Microsoft Office is a productivity suite which integrates office tools

More information

ICS 61 Game Systems and Design Introduction to Scratch

ICS 61 Game Systems and Design Introduction to Scratch ICS 61, Winter, 2015 Introduction to Scratch p. 1 ICS 61 Game Systems and Design Introduction to Scratch 1. Make sure your computer has a browser open at the address http://scratch.mit.edu/projects/editor/.

More information

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

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller.

Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller. Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller. FACULTY OF SOCIETY AND DESIGN Building a character

More information

Introduction to Events

Introduction to Events Facilitation Guide Introduction to Events ( http://www.alice.org/resources/lessons/introduction-to-events/ ) Summary This guide is intended to guide the facilitator through the creation of events and using

More information

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity Introduction Version 1.1 - November 15, 2017 Authors: Dionysi Alexandridis, Simon Dirks, Wouter van Toll In this assignment, you will use the

More information

Alice Tutorial 2. Downloading Tutorials

Alice Tutorial 2. Downloading Tutorials Alice Tutorial 2 Downloading Tutorials Please note that all tutorial resources must be downloaded in Firefox. Navigate to the link provided to you by your class tutor. Right click on each of the tutorial

More information

Creating and Triggering Animations

Creating and Triggering Animations Creating and Triggering Animations 1. Download the zip file containing BraidGraphics and unzip. 2. Create a new Unity project names TestAnimation and set the 2D option. 3. Create the following folders

More information

Shorter of two objects and changing color V2

Shorter of two objects and changing color V2 Shorter of two objects and changing color V2 Func8ons, events and se;ng the color in sequence and randomly This is a modifica8on of the Changing Color tutorial by Susan Rodger in July 2009 By Erin Taylor

More information

Introduction to Computer Science with MakeCode for Minecraft

Introduction to Computer Science with MakeCode for Minecraft Introduction to Computer Science with MakeCode for Minecraft Lesson 4: Variables In this lesson, we ll explore the concept of a variable, an important way to store information and make your programs more

More information

Setting up A Basic Scene in Unity

Setting up A Basic Scene in Unity Setting up A Basic Scene in Unity So begins the first of this series of tutorials aimed at helping you gain the basic understanding of skills needed in Unity to develop a 3D game. As this is a programming

More information

CS 1110, LAB 3: MODULES AND TESTING First Name: Last Name: NetID:

CS 1110, LAB 3: MODULES AND TESTING   First Name: Last Name: NetID: CS 1110, LAB 3: MODULES AND TESTING http://www.cs.cornell.edu/courses/cs11102013fa/labs/lab03.pdf First Name: Last Name: NetID: The purpose of this lab is to help you better understand functions, and to

More information

Flash basics for mathematics applets Tutorial 2. Reading input text boxes and writing to dynamic text boxes

Flash basics for mathematics applets Tutorial 2. Reading input text boxes and writing to dynamic text boxes Flash basics for mathematics applets Tutorial 2. Reading input text boxes and writing to dynamic text boxes by Doug Ensley, Shippensburg University and Barbara Kaskosz, University of Rhode Island In this

More information

WideQuick Remote WideQuick Designer

WideQuick Remote WideQuick Designer FLIR ThermoVision CM training This manual is starting off with a quick instruction on how to start the system and after that there are instructions on how to make your own software and modify the FLIR

More information

Events (Alice In Action, Ch 6)

Events (Alice In Action, Ch 6) CS 101 Lecture 27 Events (Alice In Action, Ch 6) 31 July 2013 Slides Credit: Joel Adams, Alice in Action Objectives Create new events in Alice Create handler methods for Alice events Use events to build

More information

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW

On the Web sun.com/aboutsun/comm_invest STAROFFICE 8 DRAW STAROFFICE 8 DRAW Graphics They say a picture is worth a thousand words. Pictures are often used along with our words for good reason. They help communicate our thoughts. They give extra information that

More information

PowerPoint 2016 Building a Presentation

PowerPoint 2016 Building a Presentation PowerPoint 2016 Building a Presentation What is PowerPoint? PowerPoint is presentation software that helps users quickly and efficiently create dynamic, professional-looking presentations through the use

More information

Tutorial. Creating activities in Expert mode

Tutorial. Creating activities in Expert mode Tutorial Creating activities in Expert mode 1 Index 1. Making a simple one answer activity 3 2. Making a sequencing activity... 11 3. Making a sorting activity 15 4. Some additional tips and things to

More information

HYPERSTUDIO TOOLS. THE GRAPHIC TOOL Use this tool to select graphics to edit. SPRAY PAINT CAN Scatter lots of tiny dots with this tool.

HYPERSTUDIO TOOLS. THE GRAPHIC TOOL Use this tool to select graphics to edit. SPRAY PAINT CAN Scatter lots of tiny dots with this tool. THE BROWSE TOOL Us it to go through the stack and click on buttons THE BUTTON TOOL Use this tool to select buttons to edit.. RECTANGLE TOOL This tool lets you capture a rectangular area to copy, cut, move,

More information

In Depth: Writer. The word processor is arguably the most popular element within any office suite. That. Formatting Text CHAPTER 23

In Depth: Writer. The word processor is arguably the most popular element within any office suite. That. Formatting Text CHAPTER 23 CHAPTER 23 In Depth: Writer The word processor is arguably the most popular element within any office suite. That said, you ll be happy to know that OpenOffice.org s Writer component doesn t skimp on features.

More information

You can now give this notecard to people by dragging and dropping it on their avatars.

You can now give this notecard to people by dragging and dropping it on their avatars. THE BASICS, PART 2 HOW TO MAKE AND GIVE NOTECARDS Follow these steps: 1. Click on the Inventory icon on your sidebar. 2. Click on the + at the bottom of the window. 3. Click on New Notecard. 4. When the

More information