Random.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <random>
  10. #include "Math.h"
  11. class Random
  12. {
  13. public:
  14. static void Init();
  15. // Seed the generator with the specified int
  16. // NOTE: You should generally not need to manually use this
  17. static void Seed(unsigned int seed);
  18. // Get a float between 0.0f and 1.0f
  19. static float GetFloat();
  20. // Get a float from the specified range
  21. static float GetFloatRange(float min, float max);
  22. // Get an int from the specified range
  23. static int GetIntRange(int min, int max);
  24. // Get a random vector given the min/max bounds
  25. static Vector2 GetVector(const Vector2& min, const Vector2& max);
  26. static Vector3 GetVector(const Vector3& min, const Vector3& max);
  27. private:
  28. static std::mt19937 sGenerator;
  29. };