Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * void
  3.  * points()
  4.  *
  5.  * displays points updates
  6.  */
  7.  
  8. function points()
  9. {
  10.     // if not all passengers have been dropped off
  11.     if (POINTS < POPULATION)
  12.         document.getElementById("announcements").innherHTML =
  13.             "Successful dropoff! You now have " + POINTS + " dropoff points!";
  14.     // if all passengers have been dropped off, announce
  15.     else
  16.         document.getElementById("announcements").innerHTML =
  17.             "Congratulations, you have dropped off all the passengers!";
  18. }
  19.  
  20.  
  21.  
  22. /*
  23.  * void
  24.  * dropoff()
  25.  *
  26.  * Drops up passengers if their stop is nearby.
  27.  */
  28.  
  29.  
  30. function dropoff()
  31. {
  32.     // so far no one has gotten off
  33.     var anyoneOff = false;
  34.    
  35.     // for every passenger on the shuttle
  36.     for (var person in SEATING)
  37.     {  
  38.         if (SEATING[person] != "empty")  
  39.         {    
  40.             // calculate the distance to passenger's house
  41.             var distance = shuttle.distance(HOUSES[SEATING[person].house].lat,
  42.              HOUSES[SEATING[person].house].lng);      
  43.        
  44.             // if anyone's house is within 30.0m
  45.             if (distance <= 30.0)
  46.             {
  47.                 // someone is getting off
  48.                 anyoneOff = true;
  49.            
  50.                 // clear that person's seat
  51.                 SEATING[person] = "empty";
  52.              
  53.                 /* update the seating display
  54.                   note: I chose not to re-order the seating list and to leave
  55.                  'empty seats' interspersed to reflect real life seating */
  56.                 seatDisplayUpdate();
  57.                      
  58.                 // add points to the players' total
  59.                 POINTS++;
  60.                
  61.                 // announces points update
  62.                 points();
  63.                        
  64.                 }        
  65.                                
  66.             }
  67.         }
  68.         if (anyoneOff == false)
  69.             document.getElementById("announcements").innerHTML =
  70.                 "No one to drop off here...";    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement