Alice 3 ? Java

concepcionsockΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 4 χρόνια και 11 μήνες)

241 εμφανίσεις

MOVING FROM ALICE 3 TO

JAVA

Mike R
-
D

YRDSB

NETBEANS

OVERVIEW AND WALKTHROUGH


Demo

NETBEANS

AND ALICE


Requires a simple plug
-
in downloaded from
website


Plug
-
in adds new option when you create a
project

ALICE
NETBEANS

PROJECT


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…

ANYTHING YOU CAN DO WITH JAVA…


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


SPECIAL CLASSES: PROGRAM

hmmm

a main method

initialize the program

Run the program

showInJFrame() displays the scene on a graphic canvas

SPECIAL CLASSES: SCENE


A DIVERSION:

DIMENSIONS IN THE ALICE WORLD


The Alice World is 3D, with the center being the
center of the World (0,0,0)









Without the ALICE IDE, we need to be

more professional with our placement of

objects


A Position Class has been defined which

provides an X,Y,Z coordinate


X
-
> subtracting moves right

Y
-
> subtracting moves down

Z
-
> subtracting moves towards camera

A DIVERSION:

THE
ALICE

QUATERNION


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, LET’S TAKE SOMEONE ELSE’S EXAMPLE

STARTED IN ALICE 3…









IMPORT INTO JAVA AND YOU SEE THESE
OBJECTS

THE SCENE'S
RUN

IN JAVA

ARCTIC BASKETBALL

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…


CONDITIONAL EXECUTION: IF/ELSE

if (
condition

is true) {


execute statement block1

} else {


execute
statement block2

}

condition

statement

block1

True

False

statement

block2

HASRECEIVED


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
.

CALLING HASRECEIVED


If hasReceived is true, the snowball is in the
water and it should disappear (set opacity to
zero)


ARCTIC BASKETBALL

Multiple conditions

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…


&&

ARCTIC BASKETBALL

Cascading if…else's

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…


NOTE THE { … }'S IN EACH CASE

MORE COOL STUFF…

1D AND 2D ARRAYS


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.

SORTING

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

RECURSION


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

MULTIPLE SCENES AND SCENE TRANSITION


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

THREADS


In my opinion, parallel programming grossly
neglected by Ministry and us


Alice is natively threaded (Do Together) and it
makes it natural to use this as a teaching tool


Can illustrate collisions, semaphores, etc



mitjokes

-

NetBeans Project