Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef RANDOM_H
- #define RANDOM_H
- #include <random>
- #include <time.h>
- #include <iostream>
- #include <SFML/System.hpp>
- template <class type>class Random{
- public:
- Random<type>(type _min,type _max);
- void reroll(type _max, type _min);
- type getNumber();
- private:
- type _number = 0;
- type _lastNumber = _number;
- type _incrementation = 1;
- sf::Clock _clock;
- sf::Time _timer;
- };
- template <class type> Random<type>::Random(type _min,type _max){
- reroll(_min,_max);
- }
- template <class type> void Random<type>::reroll(type _min,type _max){
- _timer = _clock.getElapsedTime();
- _lastNumber = _number;
- std::mt19937 _random(time(0) + _timer.asMicroseconds());
- std::uniform_real_distribution<type> _num(_min,_max);
- _number = _num(_random);
- /*if(_lastNumber == _number){
- _incrementation++;
- reroll(_min,_max);
- }*/
- _clock.restart();
- }
- template <class type> type Random<type>::getNumber(){
- return _number;
- }
- #endif // RANDOM_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement