Tip:
Highlight text to annotate it
X
Ok. So we have these avatars
that are going to be ... So we're going to enact that Bridge Scene.
The bridge of death .. I am not sure what it is called
and here is our guard
here's various characters there. you will have to draw these
characters
how hard do think it is to draw what have just seen on the screen?
not hard? geometry ...
and somehow putting those things on the screen
anybody put something like this on the screen before? you have?
no wonder you have so many classes! but lots of you haven't. A few have ..
and that's okay.
we have a tool that lets you just describe the geometry
and from that geometry it will automatically go and display things
that's a system called ObjectEditor, which I have written
let's just see what we can do
we can move Galahad
this is the tool ...
and I can say move
15 units in the X direction
and maybe 25 units in the Y direction.
Apply this .. It actually moved
how hard do you think is to make a character move?
again
you just move those coordinates. when you know how to draw things
you can move things also
you have to group things, right? you have to make sure only Galahad moves and not
everybody else
which means the arms and the legs of a character are grouped together
and what kind of concepts can we use to group things together?
in a programming language? classes?
objects? in fact isn't this great they are all instances of the same class
all these characters happen to be instances are the same class
they are a little different. that's okay that's different parameters
so you will learn not only how to - you will first create a line,
is a geometric object,
as something in Java. that will be an atomic object
then you have make this atomic object into composite objects
You will be composing in many ways but here you're composing basically
data structures 41 00:02:23,790 --> 00:02:28,270 so that's not too hard
but it will take you four or five weeks
I entered things through a menu, right and making menus, filling dialogue boxes
some of you know how to do it, some of you don't.
If you don't, that's okay by default this tool I have got will
automatically create these things for you okay so
you don't have to worry about that and let's make things a little bit more
interesting
by going and doing the show interpreter
command. so I did
a menu based interaction. here I'm going to actually do a
command line interaction. So I'm gonna say move
Galahad -15. so we are going to bring Galahad back
to his original position
It actually worked how hard to do you think it is to do this
what do you have to do?
yes you have to write this
interpreter
you have to somehow scan there's a class called Scanner
which will do automatic scanning for you but you
will not be able to use it. you can use it to read a line
but the actual scanning you have to do yourself and your first assignment is a
step in that direction
what else can I do I can keep typing
you know I'm not even a touch typist it'll take forever
but I can write programs and I am going to play a canned program
so next thing I am going to do is to rotate left arm
Galahad. so now I can
rotate which means you have to know enough geometry
I rotated in the anti-clockwise direction or
the clockwise direction?
Clockwise But when you normally increase angles
you you do that in the clockwise or anti-clockwise direction
in geometry? Counter clockwise
0 pi/2, pi/4 bye
in the Java the coordinate system is inverted
Y goes down, and you go clockwise
I can move, I can rotate my arms. can I combine these two things
into some
action? what what might that be?
so I can move. I can rotate my arms. I can rotate my limbs. so I might be
able to? answer: walk
beautiful! your see. ask the right questions and you get a response
(laughter)
And I can do it twice. so you have ... I started off Galahad and then I started
Arthur. two guys walking at the same time now what
concept in Java might you use here and an if you know that you
might not belong here. but you will still learn
threads! threads are basically ways to do
do multiple things at the same time
so you will learn about threads here can even if you know the time threads and have
learnt
them to some degree trust me you'll learn something. Even if you know everything I'm
going to cover
just doing the project you will learn something every time I do the project
I learn something new
so don't be worried that you wont learn enough
now we're going to fetch the Holy Grail and you know there's
a king with his Knights
and we shouldn't be walking individually and trying to find our own way to the Holy
Grail
right? we should be doing things together so
I want to go back there and make them both match together
so if I up have the command "walk forward" to go
ten steps in X direction what command should I have to go back to where I
was
walk backward? or?
something that's very generic. every tool has it
undo!
have you ever seen walking being undone?
well you will see it here
Two undos working in parallel as threads
I hope you guys like this demo I spent a lot of time thinking about it
So now we are going to march
not very coordinated! let's undo and see how uncoordinated we are
that's a problem you have in threads when you have multiple
activities at the same time you have to coordinate them
so how many of you have been part of a marching band?
or ever marched. if you march you need a band, right?
we don't have a band here
so we going to make them wait for some drum beat
and the four of them are waiting there is another character here so what can the character do 125 00:07:30,949 --> 00:07:35,550 to make them synchronized?
conduct? he's just got his arms
so he's clapping and to the clap their walking
so that is a sync clap command so what I did was I said syncMatchForward
where they were waiting
and then each time he clapped they moved one step forward
how to do that you learn through threads
so the question is my interpreter is fairly simple
but up how many of you have used Alice?
at all other know something but Alice what does Alice do?
if you explain in English? is this somewhat
can you see any relationship between this and Alice?
so Alice was developed by a guy called Randy Pausch
and if you don't know who this guy is google him. he was a wonderful guy
and he gave something called
the last lecture which you should all listen to
when you have time but the whole idea was .. anybody else who has done Alice?
can you see the relationship between Alice and this? Yes?
Yes
it probably had threads. yes. and you were writing programs.
basically you had a 2D environment environment right
You had an interpreter and your programming consisted of
writing things the interpreter understood
people learn programming by using the interpreter. You guys are so smart
and you are advanced programmers you will write the interpreter 150 00:09:16,060 --> 00:09:20,220 and not just write little things that say Move or rotate
you are going to write loops and so forth so you we are going to do this guy's clapping
ourselves, on the command line
and you know it won't be that hard. I mean it will be hard but I will help you
so what we are going to do is
we are going to describe clapping
not in Java okay. sync clap called a java method
I am going to use our own language to write syncClap
okay so these guys are going to sync march forward they are waiting for that
method to be written and called
I'm going to define ... this one says ... you guys wanna
interpret what this really means
what am I saying here can you read it?
I am defining a procedure
no classes. that's too complicated for us i'm saying guard armsIn
that's what he does, when he claps that means rotate left arm
by certain degree. rotate right arm by a certain degree
that's my arms in. arms out?
is just do the opposite action. so you guys will actually be defining these things
and now I'm going to show you how this is working. now I am defining a method called
beat
which says call guard arms in, then proceed all proceed all means you tell the people
waiting
go ahead. stop waiting
and sleep 500 - sleep for 500 units
so that you can see this on the screen that's what we do clap at a
certain rate
and so forth. all these things will make much more sense later
but right now I'm showing you how this is working
you said "scanning" what does scanning mean? scanning means taking a bunch of text
and breaking it up into tokens. so we had this text here, we broke it up into
tokens
these tokens were broken up into then a sort of sentence
that's my parsing and based on that parsing I said okay
I have a method called guard arms in and whenever somebody says call that
please execute this piece of code. interpret this
whenever somebody says guard arms out
please do this action. whenever somebody says beat
say guard arms in, proceed all, sleep so this is the kind of data structure you are
building
If you are lost at this point you should be
you just got an idea what's going on and
you guys are not packing your bags, thank you
let me just show you this. so now I will actually showin you
how the scanning actually works. and if you can just wait two minutes
okay this is going to beats it got the token define
it's got that repeat its it's just searching for blanks and
and not its got another token
it's got this token here
and you know
and fine, now we have the tokens and now we
have this sentence and now the table should get populated and
and the table did get populated and
let me just get rid of this
rid of this.
rid of thia.
now you see the clapping is happening
must slower because you're making it this is the clapping caused by
thread beats. this is saying please call thread beats
okay and
you know I hate to stop at this point
but we haven't even gotten to the dialogue so what I will do is we will start with the dialogue
next time
and we will finish this topic