Skip to content

Instantly share code, notes, and snippets.

@mbcharbonneau
Created April 17, 2010 01:23
Show Gist options
  • Save mbcharbonneau/369161 to your computer and use it in GitHub Desktop.
Save mbcharbonneau/369161 to your computer and use it in GitHub Desktop.
- (void)move;
{
if ( self.feeding || self.prey == nil )
return;
// Add new velocity towards prey.
double x = ( self.prey.position.x - self.position.x ) / PREDATOR_VECTOR_FRACTION;
double y = ( self.prey.position.y - self.position.y ) / PREDATOR_VECTOR_FRACTION;
self.velocity = AddVector( self.velocity, MakeVector( x, y) );
[self limitVelocity];
[super move];
// Kill any unlucky boids and pause for a moment.
[self feed];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment