-
Notifications
You must be signed in to change notification settings - Fork 0
/
boid.h
34 lines (25 loc) · 887 Bytes
/
boid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <SFML/Graphics.hpp>
#include "vector2.h"
class Boid{
public:
Boid(double xCoord, double yCoord, float size);
void updateVelocity(std::vector<Boid> nearbyBoids, bool scatter);
void updatePosition(float dt);
void draw(sf::RenderWindow& window);
void setBoundingBox(Vector2 min, Vector2 max);
Vector2 getPosition();
Vector2 getVelocity();
private:
Vector2 attractRule(std::vector<Boid> nearbyBoids);
Vector2 repelentRule(std::vector<Boid> nearbyBoids);
Vector2 velocityRule(std::vector<Boid> nearbyBoids);
void capVelocity();
Vector2 boundPosition();
float getForwardAngle();
void limitVelocity();
sf::ConvexShape shape;
Vector2 position;
Vector2 velocity;
Vector2 minBounding;
Vector2 maxBounding;
};