Sie sind auf Seite 1von 44

academy.oracle.

com

Creating an animation
with Alice 3
“Careful What You Are
Looking For”
Beginner
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
2

What is Java?
Java is a programming language and computing platform
developed by Sun Microsystems in 1995. Java runs on more than
850 million personal computers worldwide, and on billions of
devices worldwide, including mobile and TV devices.
What can I do with Java?
Java allows you to:
• Play online games
• Chat with people around the world
• Use interactive maps
• View images in 3D

Where can I find Java?


From laptops to datacenters, game consoles to scientific
supercomputers, cell phones to the Internet, Java is everywhere!

What is Alice?

Alice is an innovative block-based programming environment


that makes it easy to create animations, build interactive
narratives, or program simple games in 3D.

Unlike many of the puzzle-based coding applications Alice


motivates learning through creative exploration.

Alice is designed to teach logical and computational thinking


skills, fundamental principles of programming and to be a first
exposure to object-oriented programming.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
3

Careful What You Are Looking For


Level – Beginner

Topic Details
Overview In this tutorial, you will practice using
keyboard controls to manipulate objects
in an animation. You will work with
collision detection and markers to
position the camera in your scene.

Key Concepts • Use keyboard controls to manipulate


objects in an animation
• Using invisible objects for collision
detection
• Automating random character
movements
• Using markers to place objects

Difficulty Beginner: This tutorial is appropriate for


someone who has used Alice 3 to:
• Add and position objects in a scene
• Code programming statements in the
Code editor
• Randomize movements
• Declare a user-defined procedure
• Create an animation that uses a
control statement to control animation
timing
• Use functions to control movement
based on a return value
• Use the IF control structure to affect
execution of instructions
• Use the WHILE control structure to
create a conditional loop for repetitive
behavior
• Create an expression to perform a
math operation
• Use variables in a program

Duration 90 minutes

Notes This tutorial was built using Alice 3.4.0

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
4

Alice 3 Scenario - Beginner


Careful What You Are Looking For

Part 1: Define the Scenario

Review the scenario and complete the corresponding animation.

Scenario
The player navigates a vehicle around a scene using their keyboard keys to find a hidden object. A keyboard-controlled
Humvee searches around a scene for a hidden treasure chest. If the Humvee finds the treasure chest, the chest opens,
revealing the treasure.
Program Design

To create an animation for the given scenario you need to plan it before starting any coding.

1. You need to think about the characters that you will have in your animation.

2. Plan the characters opening positions.

3. Plan the characters actions.

4. Plan the script that will be used for the conversation.

1. Characters

1 Humvee, 1 Witch, 2 Trolls, 1 Treasure Chest, 1 Potion, 1 Cauldron, 1 Cylinder and trees as props.

2. Opening Positions

The Humvee is in the center of the world facing away from the camera.

The Witch, Cauldron, Treasure Chest and potion are in the top right of the screen.

The Trolls are on opposite sides of the screen facing the Humvee.

There are trees spread round the edges of the world to form a small clearing.

The cylinder is placed between the Humvee and Witch and will be used for collision detection.

3. Character Actions

The Trolls will walk randomly around the screen

The Humvee will be controlled by the user and will move forward, backward, left and right.

The Humvee can crash into a

The witch will cast a spell that makes the Humvee disappear.

4. Script

The Witch will say “You found my hidden treasure, hahahahah, my potion will make you disappear”.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
5

Part 2: Create the Scene


Complete the following tasks:

1 Create a folder on your computer or USB drive called Alice 3 Projects. This is where you will store all your projects.

2 Launch (double-click) Alice 3

3 Select the Swamp template, then click OK.

4 In the File menu, select Save As...

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
6

5 Enter the project name Careful_What_You_Are_Looking_For. Click Save.

HINT: Save projects frequently to avoid losing your work.

6 Click on Setup Scene so that you can place your characters in their starting positions.

7 From the Search Gallery add the following objects to your world placing them in the center of your world:
• 1 Humvee
• 1 treasure chest
• 1 witch
• 1 cauldron
• 2 trolls
• 1 potion
• 1 cylinder (hint: Shapes tab)
NOTE: Do not move or reposition these objects. This will be done in a later step.

8 Use a one shots procedure to move the camera BACKWARD by 10.0.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
7

9 Add trees to the scene and position them to create a forest with a clearing in the middle. Change the paint property to
GRAY to give them a darker look. Your scene should look something like this:

10 Move one troll to the left, behind the trees, facing the center of the scene.
Resize the troll so he is as tall as the trees.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
8

11 Move the other troll to the right, behind the trees, facing the center of the scene.
Resize the troll so he is as tall as the trees.

12 Create a camera marker named origPosition that will allow you to return the camera to its original position after you
have placed all of your objects.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
9

13 Position the witch, cauldron, treasure chest, and potion under one of the trees.
Resize them so they are roughly the size shown in the following picture.
You can move the camera to get a better look at the tree area. You can do this manually or by using a one shots
procedure like MoveandOrientToAGoodVantagePointOf and choose the witch, then make final manual adjustments
with the arrows.

14 Create a camera marker named witchPosition that will allow you to return the camera to this position at any time.

15 Use a moveAndOrientTo procedure to position the potion inside of the treasure chest.

16 Use a moveAndOrientTo procedure to move the camera back to its original position.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
10

17 Position the cylinder a few meters in front of the treasure chest.

18 Resize the cylinder so it obstructs the view of the witch, cauldron and treasure chest.

19 In the Properties panel, change the opacity of the cylinder to 0.0.

NOTE: The purpose of the invisible cylinder is for the humvee to have an object to collide with in order to stop the execution
of the while loop, then start the actions of the witch, treasure chest, and potion.
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
11

20 Use a one shots procedure to turn the humvee 0.5 to the left.

21 Your finished set-up should look like this:

Part 3: Program the Animation

Section 1: Working with collision detection

22 Go to the Code editor.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
12

23 Place a do in order at the top of myFirstMethod.

Drag a comment into the do in order.

Enter text: “The camera's vehicle is the humvee, so the camera will follow the humvee wherever it goes.”

24 Select the camera from the instance menu.

25 Drag a setVehicle procedure into the do in order in myFirstMethod.


Select the humvee as the target.

26 Drag a WHILE loop into the do in order directly under the setVehicle procedure. Select the true condition as the
placeholder value.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
13

27 Select the humvee from the instance menu.

28 Click the functions tab.

29 Drag the isCollidingWith function onto the true condition in the WHILE loop.
Select the cylinder as the target.

30 Click the down-pointing arrow next to the condition.


Select NOT this.humvee isCollidingWith this.cylinder from the menu.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
14

31 Drag a do together inside the body of the WHILE loop.

Section 2: Coding the troll walking

In this section the trolls will walk around the scene automatically while the humvee is NOT colliding with the cylinder.

32 You will declare a walking procedure in the troll class. That allows all trolls to have access to the walking code.

32a Click the classes menu.


Select the Troll class
Select +Add Troll Procedure

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
15

32b Name the procedure trollWalk. Cklick Ok.

32c Drag a comment that says “Make the troll walk realistically” to the top of the procedure

32d Drag a count control statement into the trollWalk procedure.


Select 2 as the count value.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
16

32e Drag a do in order into the count statement.

32f Drag another do in order inside of the existing do in order.

32g Select the getLeftHip from the instance menu.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
17

32h Drag a turn procedure inside of the do in order.


Select arguments: BACKWARD → 0.125.

32i Drag a do together inside of the do in order, below the turn procedure.

32j Drag a turn procedure inside of the do together.


Select arguments: FORWARD → 0.125.

32k Select this from the instance menu.

32L Drag a move procedure inside of the do together.


Select arguments: FORWARD → 0.25.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
18

32m Copy the do in order statement that contains the procedures and paste it directly underneath itself.

32n Change the object references for the turn procedures in the second do in order from the left hip to the right hip.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
19

33 You are now going to make the troll turn by a random value every time it completes the step sequence.

33a Drag a turn procedure to the bottom of the trollWalk procedure.

Select arguments: LEFT → 0.5.

NOTE: 0.5 is a placeholder value and will be changed in the next step.

33b Select the down-pointing arrow next to the 0.5 value in the turn procedure.

Select Random.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
20

Select nextRandomNumberInRange ??? ???

Select Custom DecimalNumber for the low value, and 0.25 for the high value. When the calculator appears for you to
enter the low value, enter 0.02.

Leaves your code looking like this:

34 You are now going to write code that will make the troll turn in one of three directions. You will need to create a parameter
that can store a decimal value between 0 and 2. If the value is less than 0.7 the troll will turn left, if the value is more than
1.4 the troll will turn right otherwise it will walk straight on.

34a Click on the Add Parameter button to create a parameter with the following values:

Select DecimalNumber as the value type.

Input dirValue as the parameter name.

34b Drag an if statement to the bottom of the trollWalk procedure.

Select true as the value (This is a placeholder and you will change this in the next step).

Drag the turn statement into the first drop statement here section of the if statement.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
21

34c Select the down-pointing arrow next to the true value in the if statement.

Select Relational (DecimalNumber).

Select ??? < ???

Select dirValue as for the first value , and Custom DecimalNumber as the second value.

When the keypad appears for you to enter the second value, enter 0.7.

35c Drag a second if statement into the else section of the existing if statement.

Drag an if statement to the bottom of the trollWalk procedure.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
22

Select true as the value (This is a placeholder and you will change this in the next step).

Copy and paste the turn statement from the first part of the original if into the first part of the new if.

Change the turn direction from LEFT to RIGHT.

35d Select the down-pointing arrow next to the true value in the else if statement.

Select Relational (DecimalNumber).

Select ??? > ???

Select dirValue as for the first value , and Custom DecimalNumber as the second value.

When the keypad appears for you to enter the second value, enter 1.4.

35e Drag a comment that says “The troll will turn in a random direction based on the value passed in the parameter” just
above the first if statement.

35f You completed trollWalk procedure will look like this:

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
23

36 Go back to the myFirstMethod tab.

37 You will now create the procedure calls required to make the trolls walk in your program. As the trollWalk procedure has
a parameter you will need to pass a decimal value through when you call it. For this you will pass through a random
value between 0.0 and 2.0.

37a Select the troll from the instance menu.

37b Drag the trollWalk procedure into the do together contained inside the while loop.

Select 1.0 as the placeholder value when prompted.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
24

37c Select the down-pointing arrow next to the 1.0 value in the dirValue part of the trollWalk procedure call.

Select Random.

Select nextRandomNumberInRange ???, ???

Select Custom DecimalNumber as for the first value , and 2.0 as the second value.

When the keypad appears for you to enter the custom value enter 0.0.

37d Copy the trollWalk procedure call and paste it directly underneath itself.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
25

37e Change the object reference from troll to troll2 for the second procedure call.

38 Save and Run the animation. You can use the speed bar to speed up the animation to test the randomness of the trolls
turns!

Section 3: Coding the witch talking

In this section you will declare a procedure for the witch’s talking motion, and program the other motions for the witch.

39 Drag a comment tile into the botttom of myFirstMethod.

Enter text: “When the while loop's condition is no longer true, the witch talks, the treasure chest opens, and a
potion appears that makes the humvee change color then disappear.”

40 You are now going to create a procedure that will animate the witch when she speaks.

40a Select the Witch from the classes menu.

Click +Add Witch Procedure.

Name the procedure witchTalk.

Click OK.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
26

40b Drag a count control statement into the witchTalk procedure.


Select 2 as the count value.

40c Drag a do together into the count statement.

40d Drag a do in order inside of the do together.

40e Select the mouth from the instance menu.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
27

40f Drag a turn procedure inside of the do in order.

Select arguments: FORWARD → 0.125.

40g Drag another turn procedure inside of the do in order under the existing one.

Select arguments: BACKWARD → 0.125.

40h Drag a do in order inside of the do together.

40i Drag a do together inside of the second do in order.

40j Select the left shoulder from the instance menu.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
28

40k Drag a turn procedure inside of the do together.

Select arguments: BACKWARD → 0.125.

40L Copy the turn statement and paste it directly underneath itself.

Change the object reference from getLeftShoulder to getRightShoulder.

40m Copy the do together statement and paste it directly underneath itself inside the “drop statement here”.

Change the BACKWARD direction arguments to FORWARD.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
29

41 Go back to the myFirstMethod tab.

42 Drag a do in order into myFirstMethod under the last comment that you added.

43 Select the camera from the instance menu.

44 Drag a moveAndOrientTo procedure into the do in order.

Select witchPosition as the target.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
30

45 Drag a do together into the do in order statement.

44 Select the witch from the instance menu.

45 Drag the witchTalk procedure into the do together.

46 Drag a do in order inside of the do together.

47 Drag a say procedure into the do in order.

Enter text: “You found my hidden treasure!”

Change the duration to 2.0.

48 Drag a say procedure into the do in order.

Enter text: “AHAHAHAHAHAHA”

49 Drag a say procedure into the do in order.

Enter text: “My potion will make you disappear!”

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
31

50 Select the camera from the instance menu.

51 Drag a moveAndOrientTo procedure into the do in order after the do together.

Select origPosition as the target.

52 Again at this point you will not be able to see if your code works as expected as there is no way of stopping the while
loop. To test your code you can copy (CTRL key + mouse drag) and paste it to the top of myFirstMethod

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
32

52a

52b Save and run the animation.

52c Once you have checked that your code runs as expected you can delete the code block at the top.

53 You have not added any internal comments to the new code block. It is important to add comments to explain what
your code is doing.

53a Drag a comment that says “The camera moves to the witch's position” to just above the first moveAndOrientTo
statement.

53b Drag a comment that says “The witch moves and talks” to just above the do together statement.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
33

53c Drag a comment that says “The camera moves to the original position” to just above the second moveAndOrientTo
statement.

Section 4: Coding the witch casting a spell

In this section you will program the actions for the treasure chest lid and potion.

54 Drag a do in order statement above the comment that explains the camera moving back to the original position.

55 Drag a comment that says “The chest lid opens and the potion comes up changing the color of the cauldron” to just
above the do in order statement.

56 Select the treasure chest lid from the instance menu.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
34

57 Drag a turn procedure into the do in order.

Select arguments: BACKWARD → 0.25.

58 Drag a do together into myFirstMethod.

59 Select the potion from the instance menu. You may have to go through the props option to find the potion.

60 Drag a move procedure into the do together.

Select arguments: UP → 1.0.

61 Drag a turn procedure into the do together.

Select arguments: LEFT → 8.0.

Change the duration to 2.0.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
35

62 Select the cauldron from the instance menu. You may have to go through the props option to find the potion.

63 Drag the setPaint procedure into the do in order under the do together.

Select argument: MAGENTA.

64 Drag a do in order statement below the statement that explains the camera moving back to the original position.

65 Drag a comment that says “The humvee spins around, disappears and the potion goes back into the chest” to just
above the do in order statement.

66 Drag a comment that says “The humvee changes color and then disappears” into the do in order statement.

67 Drag a do together statement inside of the do in order.

68 Select the humvee from the instance menu.

69 Drag the setPaint procedure into the do together.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
36

Select argument: MAGENTA.

70 Drag the turn procedure into the do together.

Select arguments: LEFT → 8.0.

Change the duration to 2.0.

71 Drag the setOpacity procedure into the do together.

Select argument: 0.0.

Change the duration to 2.0.

72 Drag a comment that says “The potion goes back down and the chest lid closes” under the do together statement (but
still in the do in order).

73 Select the potion from the instance menu.

74 Drag a move procedure under the comment.

Select arguments: UP → 1.0.

75 Select the treasure chest lid from the instance menu.

76 Drag the turn procedure under the move statement.

Select arguments: FORWARD → 0.25.

77 Select the cauldron from the instance menu.

78 Drag the setPaint procedure under the turn statement.

Select argument: WHITE.

79 Again at this point you will not be able to see if your code works as expected as there is no way of stopping the while
loop. To test your code you can copy (CTRL key + mouse drag) and paste it to the top of myFirstMethod. Delete the
copied code when you have completed your testing!

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
37

Section 5: Coding the event handler to move the humvee

In this section you will program the keyboard controls for the humvee.

80 Click the initializeEventListeners tab.

81 You are now going to create theevent that will allow you to use the keys to control the movement of the humvee.

81a Click the Add Event Listener button.

81b Select Keyboard and then select addKeyPressListener.

81c Drag a acomment into the keyPressed procedure that says “Move the humvee depending on the users key press!”

81d Drag an if statement inside the body of the keyPressed procedure.

Select the true condition as the placeholder value.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
38

81e Drag the event isKey key ??? tile onto the true condition.

81f Select the W key.

81g Drag a do together inside of the if statement.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
39

81h Select the humvee from the instance menu.

81i Drag a move procedure inside of the do together.


Select arguments: FORWARD → 1.0.

Set the animation style to BEGIN AND END ABRUPTLY

Set the duration to 0.2 seconds

81j Right-click the if statement and choose copy to clipboard.

81k Drag the code from the clipboard into the else statement of the keyPressed procedure.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
40

81L For the copied code:

Change the W key to Z.

Change the FORWARD direction arguments in each procedure to BACKWARD.

81m Copy the second if statement into the else in the same way as you did before.

Change the S key to A.

Change the BACKWARD direction arguments in each procedure to FORWARD.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
41

81n Copy the third if statement into the else in the same way as you did before.

Change the A key to D.

81o Run and test your code. At this stage the S key will make the humvee go backwards, the other three keys will make it go
forward. No other key should have an affect on the humvee!

82 You are now going to amend your code so that the humvee will turn when going forward if the A or D keys are pressed.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
42

82a Drag a turn procedure into the if statement that is executed when the A key is pressed.

Select arguments: LEFT → 0.05.

82b Drag a turn procedure into the if statement that is executed when the D key is pressed.

Select arguments: RIGHT → 0.05.

82c Run and test your code.

83 You are now going to test that your code works properly when the humvee collides with the cylinder.

83a For testing purposes you can set the opacity of the cyclinder to 0.5 in setup scene.

83b Run the program and collide the humvee and the cyclinder.

83c If it does not work then you may have to move the cylinder further out from the witch.

83d When you collision occurs the whole world will spin round which is not what was intended. This is because the camera’s
vehicle property is set to the humvee, when you spin the humvee you spin the camera.

In myFirstMethod select the camera from the instance menu.

Drag a setVehicle procedure into the do in order above the comment that states “The humvee changes color and
disappears”

Select this as the vehicle. (NOTE: this sets the camera back to the world!)

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
43

83e If the humvee obscures the witch’s spell then move the cylinder to some other place within the world.

83f Set the opacity of the cylinder back to 0.0 in setup scene.

83g Save and Run the animation.

Task: Now it is your chance to play with your new Alice 3 skills!

Add additional actions

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
44

84 Now that you have finished this tutorial, continue to experiment with the features of Alice 3.

84a Add additional magic creatures that move about the world.

84 b Create a color variable that will control the color of the potion and the spell.

Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.