Advertisement
Guest User

LLL

a guest
Jul 3rd, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #ifndef RANDOM_H
  2. #define RANDOM_H
  3. #include <random>
  4. #include <time.h>
  5. #include <iostream>
  6. #include <SFML/System.hpp>
  7. template <class type>class Random{
  8.     public:
  9.         Random<type>(type _min,type _max);
  10.         void reroll(type _max, type _min);
  11.         type getNumber();
  12.     private:
  13.         type _number = 0;
  14.         type _lastNumber = _number;
  15.         type _incrementation = 1;
  16.         sf::Clock _clock;
  17.         sf::Time _timer;
  18. };
  19. template <class type> Random<type>::Random(type _min,type _max){
  20.     reroll(_min,_max);
  21. }
  22. template <class type> void Random<type>::reroll(type _min,type _max){
  23.     _timer = _clock.getElapsedTime();
  24.     _lastNumber = _number;
  25.     std::mt19937 _random(time(0) + _timer.asMicroseconds());
  26.     std::uniform_real_distribution<type> _num(_min,_max);
  27.     _number = _num(_random);
  28.  
  29.     /*if(_lastNumber == _number){
  30.         _incrementation++;
  31.         reroll(_min,_max);
  32.     }*/
  33.     _clock.restart();
  34. }
  35. template <class type> type Random<type>::getNumber(){
  36.     return _number;
  37. }
  38. #endif // RANDOM_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement