Upload
gregory-cunningham
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
Imports all necessary packages/libraries
Students only need to worry about ‘Source Packages’
All of the Alice classes are shown as Java classes.
This means…
you can do with Alice!!!!
Teach advanced Java concepts with ease (Sorting, Recursion, 2D Arrays, Dynamic Programming)
Implement a Text-Speech Alice Storyteller with JSAPI
Alice 3.0 mail interface for children using javax.mail
hmmm
a main method
initialize the program
Run the program
showInJFrame() displays the scene on a graphic canvas
The Alice World is 3D, with the center being the center of the World (0,0,0)
Without the ALICE IDE, we need to bemore professional with our placement ofobjects
A Position Class has been defined whichprovides an X,Y,Z coordinate
X-> subtracting moves rightY -> subtracting moves downZ -> subtracting moves towards camera
normally you will move and rotate objects using the Alice methods
I’m going to cheat a little A Quaternion represents rotations in 3D
space (a,b,c,d)
a: forward/backward rotation b: right/left turn c:right/left rotation d: haven’t taken math in 15 years
So far… we have the penguins each pushing a snowball a random distance… is the snowball in the water?
Do in order penguin1.push snowball1 a random distance
penguin2.push snowball2 a random distance
if snowball1 and snowball 2 are both in the water penguin1.swagger penguin2.swagger
else if snowball1 is in the water penguin1.swagger
else if snowball2 is in the water penguin2.swagger
else neither is in the water
try again…
if (condition is true) { execute statement block1
} else { execute statement block2
}
conditioncondition
statementblock1
statementblock1
True False
statementblock2
statementblock2
hasReceived is a <typed> method (function) that returns true if a snowball's location is within the radius of the holeInIce (a blue circle object in the scene), otherwise it returns false.
Multiple conditionsDo in order penguin1.push snowball1 a random distance
penguin2.push snowball2 a random distance
if snowball1 and snowball 2 are both in the water penguin1.swagger penguin2.swagger
else if snowball1 is in the water penguin1.swagger
else if snowball2 is in the water penguin2.swagger
else neither is in the water
try again…
Cascading if…else'sDo in order penguin1.push snowball1 a random distance
penguin2.push snowball2 a random distance
if snowball1 and snowball 2 are both in the water penguin1.swagger penguin2.swagger
else if snowball1 is in the water penguin1.swagger
else if snowball2 is in the water penguin2.swagger
else neither is in the water
try again…
You should have guessed by now that with our transition to Java comes the ability to have 2D and 3D arrays [something that any 3D world should have
Think of how painstaking it was to create an array of Sims in Alice 3.0. Now, let me demo.
public void sort(int[] x){ for (int counter = 0; counter < 10; counter++) { //Loop once for each element in the
array. for (int index = 0; index < 10 - 1 - counter; index++) { //Once for each
element, minus the counter. if (x[index] < x[index + 1]) { //Test if need a swap or not. int temp = x[index]; //These three lines just swap the two elements:
x[index] = x[index+1]; x[index + 1] = temp; } }}
Sorting elements in Alice is just a matter of replacing x with an object array and adding code to animate the move
Tired of textual Towers of Hanoi?
Bored with Fib Fib-Fib Fib-Fib-Fibonacci?
Bring Alice into the equation and in a few minutes have a Recursive Party
multipleScenesAlice NetBeans Project
One of the number 1 requests Alice 2 couldn’t handle. Storybook Alice tried, but was weak.
Still a little glitchy, but piece of cake in Alice 3.0
Also makes group collaboration a cinch