CSC3224_Computer_Games_Development / GameEngine / Engine_Common / Common.h
Common.h
Raw
#pragma once
#include <stdlib.h>
// All Engine #defines

#define FONT_DIR "../GameEngine/Engine_Resources/Fonts/"
#define GAME_LEVEL_DIR  "../GameEngine/Engine_Resources/GameLevels/"
#define KEY_MAPPING_DIR  "../GameEngine/Engine_Resources/KeyMapping/"
#define SHADER_DIR  "../GameEngine/Engine_Resources/Shaders/"
#define SOUND_DIR  "../GameEngine/Engine_Resources/Sounds/"
#define TEXTURE_DIR  "../GameEngine/Engine_Resources/Textures/"

#define MAX_NR_OF_ENGINE_EventS 2048
#define SCALE_PIXELS_TO_UNITS 20.f
#define MAX_NO_OF_SYSTEMS 2048
#define MAX_NO_OF_TEXTURES 256
#define MAX_NO_OF_SOUNDS 1024
#define MAX_NO_OF_ENTITIES 1024


template <typename T>
constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
	return clamp(v, lo, hi, std::less<>());
}

template <typename T, typename Compare>
constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp) {
	return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
}

inline float RandomFloat(float a, float b)
{
	float random = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
	float diff = b - a;
	float r = random * diff;
	return a + r;
}