forked from jakogut/tinyflock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboid.h
39 lines (25 loc) · 854 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
35
36
37
38
39
#ifndef BOID_H_
#define BOID_H_
#include <SDL.h>
#include "flockconfig.h"
#include "vector.h"
typedef struct
{
SDL_Surface* sprite;
// Where the boid is on the screen
vector* location;
// Whether the boid's speed is increasing or decreased, and in what direction
vector* acceleration;
// What direction the boid is moving in, and at what speed
vector* velocity;
} boid;
boid* create_boid(SDL_Surface* image, int loc_x, int loc_y, int vel_x, int vel_y);
void destroy_boid(boid* b);
// Avoid crowding flockmates
vector* flock_separate (boid** flock, boid* b);
// Head in the same average direction as flockmates
vector* flock_align(boid** flock, boid* b);
// Head towards the average position of flockmates
vector* flock_cohere(boid** flock, boid* b);
void flock_limit_velocity(boid** flock, int num_boids, float max_velocity);
#endif