Created
January 13, 2021 05:59
-
-
Save rvishwajith/7dc01980213120989c7d78f3b8f627bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 vairable 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) | |
// limiting speed after all changes to velocity | |
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