Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University,...
-
Upload
oswald-foster -
Category
Documents
-
view
216 -
download
4
description
Transcript of Distance Challenge By: Chris Brown Under the direction of Prof. Susan Rodger Duke University,...
Distance Challenge
By: Chris BrownUnder the direction of Prof. Susan Rodger
Duke University, January 2013
Problem• It’s Jimmy’s first time in a new city, and we need
to help him find his way around! He knows where he is located in the center at (0, 0) to start, and he also knows the coordinates of each place he wants to visit. Your job will be to fill in the distance function, to calculate the distance from Jimmy to his destination. You can move around the city by clicking on the different places of interest that you want to visit.
• 1 unit = 1 meter
ProblemWe want to calculate this distance!
(9, -4)
(0, 0)
Problem
• Now, Jimmy wants to go from the theme park to the museum…
(9, -4)
(-6, -6)
world.distance
• Each time the distance function is called, four parameters are passed in with information you will need. It provides you with Jimmy’s x value, Jimmy’s y value, the destination’s x value, and the destination’s y value. It is your job to correctly return the distance from Jimmy to his destination in this function.
• Hint: What is the distance formula? It can be derived from Pythagorean’s Theorem.
world.distance
Fill this in!
Bonus Challenge!• Go into the Alice Object
Gallery to add new places, with an original animation every time Jimmy visits that place. Make sure to create variables for your location’s x and y position to be passed into your distance function later on.