Vehicles and Conditionals

Download Report

Transcript Vehicles and Conditionals

Vehicles and Conditionals
By Henry Qin, edited and revised by
Ruthie Tucker, under the direction of
Professor Susan Rodger, Duke
University 2008
Getting Started
• To build this world, we
will need a vehicle
and a person. I am
using the Humvee
and Euripides. You
can use whichever
characters you would
like.
Getting Started
• We are going to make several events in
this world.
• The mouse will move both your vehicle
and your person separately.
• When you click on the “T” key the mouse
should move both of them together, as if
they were glued together.
• We will then create a second world that
uses the “T” key to control the camera.
World.ChangeVehicle
• First we will need to
create a new method,
called
world.changevehicle.
World.ChangeVehicle
• Now we need to drag an
“if statement” into the
newly created method.
• Now we want to make the
world do something if
Euripides is set as a
vehicle to the Humvee.
World.ChangeVehicle
• Now if the condition is
true we will set Euripides’
vehicle to the entire
world.
World.ChangeVehicle
• Else the vehicle for
Euripides will be set
to the Humvee.
World.ChangeVehicle
• Now we need to
implement some events
• The first event we need is
“let the mouse move.”
• We need to create a new
variable to place in the
space of “Any Object.”
Creating more events
• Now we need another
event to implement our
method to make
Euripides and the
Humvee move together.
• Create a new event
labeled “when a key is
typed” and select the
letter T.
Creating the Events
• Now we can implement
our “Change Vehicle”
method.
• This will make Euripides
and the Humvee move
together.
Finishing Up Part One
• Now try playing your
world.
• First click on Euripides
and the Humvee and see
if they move separately
• Now move Euripides on
top of the Humvee and
hold down the “T” key.
• Now when you click on
the Humvee Euripides
should move with it.
Adding Camera Control
In order to do the final part we will need to start a new
world that has the same objects in it as before. See
below.
Adding Camera Control
Once you have added
your objects, put
Euripides on the
Humvee and set him as
a vehicle to the Humvee.
Now create an event using the
arrow keys to drive the
Humvee.
Adding Camera Control
Now we want to
create a new world
level method labeled
just like the old one,
“World.ChangeVehic
le.”
Now lets place an if/else
statement inside our new method.
Adding Camera Control
Now set the camera's
vehicle to the Humvee in
the “if statement”.
Adding Camera Control
We want the Camera to be set as a vehicle to the
world if the statement is true. Else it should be set
to the Humvee.
Adding the Final Event
Go to the events editor and
add a second event that
involves pressing the “T”
key.
In the “Do Nothing” category add
“World.ChangeVehicle.”
Testing the World
Now try playing your world. The
arrow keys should move the
Humvee with Euripides
attached to it.
Finishing Up
Now hit the “T” key and try
moving your arrow keys
again. This time the camera
should follow your Humvee
while you move around.
That's all folks!