Created
January 13, 2021 05:56
-
-
Save rvishwajith/f4d77cc2543b5cd593be73314264c423 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
Boids[] // this is a global variable accesible in other methods | |
Update() | |
FOR b in Boids | |
vector1 = rule1(b) // Boids flock to the center of mass | |
vector2 = rule2(b) // Boids avoid other boids | |
vector3 = rule3(b) // Boids try to match the speed of other boids | |
// additional rules can be added directly after | |
vector4 = rule4(b) | |
vectorX = ruleX(b) | |
finalVector = vector1 + vector2 + vector3 ... + vectorX | |
b.velocity += finalVector // Adjust direction and speed | |
b.position += b.velocity // Update the position to the new position |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment