Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
engine_utils.h
Go to the documentation of this file.
1/*
2 engine_utils.h
3 Nicolas Chereau 2006
4 Olympe Engine ::2D Game Editor ::olympe.editor@gmail.com
5 nchereau@gmail.com
6*/
7
8#pragma once
9
10#include "vector.h"
11#include <SDL3/SDL.h>
12#include <random>
13
14//////////////////////////////////////////////////////////
15// MACROS
16#define MAX(a,b) (((a) > (b)) ? (a) : (b))
17#define MIN(a,b) (((a) < (b)) ? (a) : (b))
18
19//////////////////////////////////////////////////////////
20//MESSAGE & LOG
21void MsgBox(string& stitle, string& smsg, bool _berror = false);
22
23//////////////////////////////////////////////////////////
24// RANDOM
25inline int Random_Int(const int a, const int b) { return SDL_rand(b - a); }
26inline float Random_Sign(void) {if (Random_Int(0, 1)) return 1.0f; else return -1.0f;}
27inline float Random_Float(const float a, const float b) {return (float) (Random_Int((int)a, (int)b) + SDL_randf() );}
28
29inline Vector Random_Vector(const float a, const float b) {return Vector(Random_Float(a, b),Random_Float(a, b),Random_Float(a, b));}
30inline Vector Random_Point(const Vector p1, const Vector p2) {return Vector(Random_Float(p1.x, p2.x),Random_Float(p1.y, p2.y),Random_Float(p1.z, p2.z));}
31inline Vector Random_Point(const Vector p, const float r) {return Vector(p.x + Random_Float(0.0f, r) * Random_Sign(), p.y + Random_Float(0.0f, r) * Random_Sign(), p.z + Random_Float(0.0f, r) * Random_Sign());}
32inline SDL_Color Random_Color(const int a = 0, const int b = 255) { SDL_Color col /*RGBA*/ = { (unsigned char)Random_Int(a, b), (unsigned char)Random_Int(a, b), (unsigned char)Random_Int(a, b), 0xFF }; return col; }
33
34//////////////////////////////////////////////////////////
35// Clamp a float into a range
36float FloatClamp (float _f, float fMin, float fMax);
37int IntClamp (int _i, int iMin, int iMax);
39float fBlend ( float _f1, float _f2, float _fc);
40
41
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
SDL_Color Random_Color(const int a=0, const int b=255)
Vector Random_Vector(const float a, const float b)
Vector Random_Point(const Vector p1, const Vector p2)
float fBlend(float _f1, float _f2, float _fc)
Vector VectorClamp(Vector _v, Vector _vMin, Vector _vMax)
float Random_Sign(void)
float Random_Float(const float a, const float b)
int Random_Int(const int a, const int b)
void MsgBox(string &stitle, string &smsg, bool _berror=false)
int IntClamp(int _i, int iMin, int iMax)
float FloatClamp(float _f, float fMin, float fMax)