Title: Vehicles and Conditionals
 1Vehicles and Conditionals
- By Henry Qin, edited and revised by Ruthie 
Tucker, under the direction of Professor Susan 
Rodger, Duke University 2008 
  2Getting 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. 
  3Getting 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.  
  4World.ChangeVehicle
- First we will need to create a new method, called 
 world.changevehicle. 
  5World.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. 
  6World.ChangeVehicle
- Now if the condition is true we will set 
Euripides vehicle to the entire world. 
  7World.ChangeVehicle
- Else the vehicle for Euripides will be set to the 
Humvee. 
  8World.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.  
  9(No Transcript) 
 10(No Transcript) 
 11Creating 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. 
  12Creating the Events
- Now we can implement our Change Vehicle method. 
 
- This will make Euripides and the Humvee move 
together. 
  13Finishing 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. 
  14Adding 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. 
 15Adding 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. 
 16Adding Camera Control
Now we want to create a new world level method 
labeled just like the old one, World.ChangeVehicl
e.
Now lets place an if/else statement inside our 
new method. 
 17Adding Camera Control
Now set the camera's vehicle to the Humvee in the 
if statement. 
 18Adding 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. 
 19Adding 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. 
 20Testing the World
Now try playing your world. The arrow keys should 
move the Humvee with Euripides attached to it. 
 21Finishing 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!