Permalink
Browse files

reversed order of subtraction to reverse movement

  • Loading branch information...
1 parent 2451372 commit 6dd7618e0c4c8f59955e970d703f5110b0222cb3 @cpdean committed Oct 24, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 zeds.js
View
12 zeds.js
@@ -111,11 +111,13 @@ var Zeds = function() {
};
this.move_to = function(food_agent) {
- // move to the other agent, landing on it or going as far
- // as possible
- function vector_to_food(food) {
- return {x : squirrel.x - food.x,
- y : squirrel.y - food.y};
+ // returns a function that updates the position of
+ // this agent, moving it as close as possible to
+ // the food agent
+ var new_x,new_y;
+ function vector_to(food) {
+ return {x : food.x - squirrel.x,
+ y : food.y - squirrel.y};
}
function scalar_multiply(vector,scalar) {

0 comments on commit 6dd7618

Please sign in to comment.