#include "headers/helpers.hpp" namespace asloengine { unsigned long long log_count = 0; void log(const std::string& prefix, const bool condition) { #ifdef DEBUG std::string new_message = condition ? "true" : "false"; log(prefix, new_message); #endif } void log(const std::string& prefix, const int number) { #ifdef DEBUG std::string new_message = std::to_string(number); log(prefix, new_message); #endif } void log(const std::string& prefix, const double number) { #ifdef DEBUG std::string new_message = std::to_string(number); log(prefix, new_message); #endif } void log(const std::string& prefix, const char* message) { #ifdef DEBUG std::string new_message = std::string(message); log(prefix, new_message); #endif } void log(const std::string& prefix, const std::string& message) { #ifdef DEBUG std::string logged_message = std::to_string(log_count++) + " - " + prefix + message; // Log into Console std::cout << logged_message << std::endl; // Log into File if (log_count == 1) { remove("log.txt"); } std::ofstream o_file("log.txt", std::ios_base::app); o_file << logged_message << std::endl; o_file.close(); #endif } sf::Vector2f operator+(sf::Vector2f _vec, float add) { return sf::Vector2f(_vec.x + add, _vec.y + add); } sf::Vector2f operator-(sf::Vector2f _vec, float subtract) { return sf::Vector2f(_vec.x - subtract, _vec.y - subtract); } sf::Vector2f operator*(sf::Vector2f _vec, float multiplier) { return sf::Vector2f(_vec.x * multiplier, _vec.y * multiplier); } sf::Vector2f operator/(sf::Vector2f _vec, float divider) { return sf::Vector2f(_vec.x / divider, _vec.y / divider); } sf::Vector2f operator+(sf::Vector2f _vec_1, sf::Vector2f _vec_2) { return sf::Vector2f(_vec_1.x + _vec_2.x, _vec_1.y + _vec_2.y); } sf::Vector2f operator-(sf::Vector2f _vec_1, sf::Vector2f _vec_2) { return sf::Vector2f(_vec_1.x - _vec_2.x, _vec_1.y - _vec_2.y); } sf::Vector2f operator*(sf::Vector2f _vec_1, sf::Vector2f _vec_2) { return sf::Vector2f(_vec_1.x * _vec_2.x, _vec_1.y * _vec_2.y); } sf::Vector2f operator/(sf::Vector2f _vec_1, sf::Vector2f _vec_2) { return sf::Vector2f(_vec_1.x / _vec_2.x, _vec_1.y / _vec_2.y); } sf::Vector2f operator+(sf::Vector2f _vec, sf::FloatRect _rect) { return sf::Vector2f(_vec.x + _rect.width, _vec.y + _rect.height); } sf::Vector2f operator-(sf::Vector2f _vec, sf::FloatRect _rect) { return sf::Vector2f(_vec.x - _rect.width, _vec.y - _rect.height); } sf::Vector2f operator*(sf::Vector2f _vec, sf::FloatRect _rect) { return sf::Vector2f(_vec.x * _rect.width, _vec.y * _rect.height); } sf::Vector2f operator/(sf::Vector2f _vec, sf::FloatRect _rect) { return sf::Vector2f(_vec.x / _rect.width, _vec.y / _rect.height); } float clamp(float value, float min, float max) { if (value < min) { value = min; } if (value > max) { value = max; } return value; } sf::Vector2i to_vector2i(sf::Vector2u _vec) { return sf::Vector2i(_vec.x, _vec.y); } sf::Vector2i to_vector2i(sf::Vector2f _vec) { return sf::Vector2i(_vec.x, _vec.y); } sf::Vector2u to_vector2u(sf::Vector2i _vec) { return sf::Vector2u(_vec.x, _vec.y); } sf::Vector2u to_vector2u(sf::Vector2f _vec) { return sf::Vector2u(_vec.x, _vec.y); } sf::Vector2f to_vector2f(sf::Vector2i _vec) { return sf::Vector2f(_vec.x, _vec.y); } sf::Vector2f to_vector2f(sf::Vector2u _vec) { return sf::Vector2f(_vec.x, _vec.y); } }