Created
April 17, 2010 01:23
-
-
Save mbcharbonneau/369161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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