Skip to content

Commit

Permalink
fix: Use a better random generator
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Jun 25, 2024
1 parent 61e24f6 commit 51fa9b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <engine/common.h>
#include <cmath>
#include <fstream>
#include <random>
#ifdef EMSCRIPTEN
#include <emscripten.h>
#else
Expand Down Expand Up @@ -105,7 +106,10 @@ float LengthDir_y(float len, float dir) {

// Returns a random number between min and max
float RandomRange(float min, float max) {
return min + (max - min) * (float)rand() / RAND_MAX;
static std::random_device rd;
static std::mt19937 gen(rd());
std::uniform_real_distribution<float> dis(min, max);
return dis(gen);
}

// Merges 2 colors
Expand Down

0 comments on commit 51fa9b0

Please sign in to comment.