aboutsummaryrefslogtreecommitdiff
path: root/include/NR_Utils.hpp
blob: 3f4c84e5fd38ba7e603759c59920a6f7a3f39c99 (plain)
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
#ifndef __NR_UTILS_HPP__
#define __NR_UTILS_HPP__

#include <sstream>

#include <Box2D.h>
#include <SFML/Graphics.hpp>

constexpr double PI         = 3.14159265;
constexpr double IN_RADIANS = 180.0 / PI;
constexpr double IN_DEGREES = PI / 180.0;

const sf::Uint32 AGENT_RAD      = 5;
const sf::Uint32 AGENT_RES      = 16;
constexpr float  AGENT_SIGHT    = 100.0f;
constexpr float  AGENT_SPEED    = 500.0f;
const sf::Color  AGENT_COLOR    = { 128,   0, 255, 128 };
const sf::Color  SIGHT_COLOR    = { 128, 128, 128,  32 };
const sf::Color  CHAMP_COLOR    = { 204, 153, 255 };
const sf::Color  SELECTED_COLOR = { 204,  53,  55 };
const sf::Color  WALL_COLOR     = { 204, 153, 255 };
const sf::Color  FACTORY_COLOR  = { 204, 153, 255 };
const sf::Color  TEXT_COLOR     = { 204, 153, 255 };
const sf::Color  CHECKPNT_COLOR = { 128, 128, 128, 128 };
const sf::Color  BG_COLOR       = {  16,   0,  32 };

const float _TIME_STEP = 1.0f / 60.0f;
const int32 _VEL_ITERS = 6;
const int32 _POS_ITERS = 2;

const sf::Uint32          WIN_SIZE     = 600;
const sf::VideoMode       VIDEO_MODE   = sf::VideoMode(WIN_SIZE, WIN_SIZE);
const sf::String          WIN_TITLE    = "NeuroRacers v0.1";
const sf::Uint32          WIN_STYLE    = sf::Style::Close;
const sf::ContextSettings WIN_SETTINGS = sf::ContextSettings(0, 0, 4);

ssize_t pMod(ssize_t n, ssize_t d);
float dist(const b2Vec2& a, const b2Vec2 b);
float dotP(const b2Vec2& a, const b2Vec2 b);

class RayCastCallback : public b2RayCastCallback {
public:
    float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction);

    const b2Fixture* _fixture  = nullptr;
    float32          _fraction = 0.0f;
};

class QueryCallback : public b2QueryCallback {
public:
    bool ReportFixture(b2Fixture* fixture);

    const b2Fixture* _fixture = nullptr;
};

class TrapCallback : public b2QueryCallback {
public:
    bool ReportFixture(b2Fixture* fixture);

    const b2Fixture* _fixture = nullptr;
};

class Stage;
class ContactListener : public b2ContactListener {
public:
    void BeginContact(b2Contact* contact);

    Stage* _stage = nullptr;
};

template <typename T>
std::string toString(const T& value)
{
    std::stringstream stream;
    stream << value;
    return stream.str();
}

#endif // __NR_UTILS_HPP__