From af7e23ab119eba7c0579796abd288c027edabfa9 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:20:22 +0100 Subject: Initial commit --- include/NR_Utils.hpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 include/NR_Utils.hpp (limited to 'include/NR_Utils.hpp') diff --git a/include/NR_Utils.hpp b/include/NR_Utils.hpp new file mode 100644 index 0000000..3f4c84e --- /dev/null +++ b/include/NR_Utils.hpp @@ -0,0 +1,79 @@ +#ifndef __NR_UTILS_HPP__ +#define __NR_UTILS_HPP__ + +#include + +#include +#include + +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 +std::string toString(const T& value) +{ + std::stringstream stream; + stream << value; + return stream.str(); +} + +#endif // __NR_UTILS_HPP__ -- cgit v1.2.1