This repository has been archived by the owner on Apr 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboids.h
107 lines (85 loc) · 1.94 KB
/
boids.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef BOIDS_H
#define BOIDS_H
#include "point.h"
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <time.h>
#include <GL/glut.h>
#include "objective.h"
#include "predator.h"
#include "rectangle.h"
#include "circle.h"
#include "TextureManager.h"
#define REGULAR_SPEED 0.4f
#define RUNNING_SPEED 0.8f
#define GRID_SIZE 400
#define LE_SIZE 800
class Predator;
struct Rectangle;
struct RandNumbers{
int rdtsc(){
__asm__ __volatile__("rdtsc");
}
};
class Boid{
private:
bool avoiding, predator;
bool mesh = true;
int grid_size;
float view_angle = 135.0f;
float view_distance = 100.0f;
float boid_speed = 0.5f;
float max_speed = 2.5f;
/*float boid_speed_x = 0.0f;
float boid_speed_y = 0.0f;*/
float center_x, center_y;
float objective_x, objective_y;
float distance_x, distance_y;
float predator_x, predator_y;
float obstacle_x, obstacle_y;
float vel_x, vel_y;
float boid_speed_x, boid_speed_y;
float acc_x, acc_y;
float move_x, move_y;
float last_move_x, last_move_y;
bool moved = false;
bool go_to_obj_only = false;
int dir, max_moves = 20, cur_moves;
Point2D* pt;
Objective* objective = nullptr;
//float getNorm(float x, float y);
void move_up();
void move_left();
void move_down();
void move_right();
void move_towards_center();
void avoid_boids();
void random_move();
void move_towards_objective();
void avoid_predator();
void avoid_obstacle();
void adapt_velocity();
public:
GLuint texture;
Boid();
int grid_x, grid_y;
void set_pt(Point2D* pt);
float get_dist();
void find_grid_pos(int size);
Point2D* get_pt();
void move();
void draw();
void draw_line();
void gen_objective();
void edges();
};
extern std::vector<Boid*> boids;
extern std::vector<Objective*> objectives;
extern std::vector<Predator*> predators;
//extern std::vector<Rectangle*> obstacles;
extern std::vector<Circle*> obstacles;
extern std::vector<Boid*>** GRID;
#endif