Implemented weather
This commit is contained in:
@@ -18,10 +18,10 @@ namespace utils {
|
||||
void _AssertInternal(bool condition, const std::string& msg, const std::string& lineText, const std::string& file, int line);
|
||||
void _AssertInternalLog(bool condition, const std::string& msg, const std::string& lineText, const std::string& file, int line);
|
||||
|
||||
#ifdef BUILD_DEBUG
|
||||
#define Assert(condition, message) farmlands::utils::_AssertInternal(condition, message, #condition, __FILE__, __LINE__)
|
||||
#else
|
||||
#ifdef NDEBUG
|
||||
#define Assert(condition, message) farmlands::utils::_AssertInternalLog(condition, message, #condition, __FILE__, __LINE__)
|
||||
#else
|
||||
#define Assert(condition, message) farmlands::utils::_AssertInternal(condition, message, #condition, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
} /* namespace utils */
|
||||
|
32
src/utils/Random.cpp
Normal file
32
src/utils/Random.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Random.cpp
|
||||
*
|
||||
* Created on: Dec 10, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#include <utils/Random.h>
|
||||
|
||||
namespace farmlands {
|
||||
namespace utils {
|
||||
|
||||
float Random::getFloat()
|
||||
{
|
||||
std::uniform_real_distribution<float> distrib;
|
||||
return distrib(m_engine);
|
||||
}
|
||||
|
||||
int Random::getInt(int min, int max)
|
||||
{
|
||||
std::uniform_int_distribution<int> distrib(min, max);
|
||||
return distrib(m_engine);
|
||||
}
|
||||
|
||||
int Random::getInt(int max)
|
||||
{
|
||||
std::uniform_real_distribution<float> distrib(0, max);
|
||||
return distrib(m_engine);
|
||||
}
|
||||
|
||||
} /* namespace utils */
|
||||
} /* namespace farmlands */
|
30
src/utils/Random.h
Normal file
30
src/utils/Random.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Random.h
|
||||
*
|
||||
* Created on: Dec 10, 2016
|
||||
* Author: tibi
|
||||
*/
|
||||
|
||||
#ifndef UTILS_RANDOM_H_
|
||||
#define UTILS_RANDOM_H_
|
||||
|
||||
#include <random>
|
||||
|
||||
namespace farmlands {
|
||||
namespace utils {
|
||||
|
||||
class Random
|
||||
{
|
||||
public:
|
||||
float getFloat();
|
||||
int getInt(int min, int max);
|
||||
int getInt(int max);
|
||||
|
||||
private:
|
||||
std::mt19937 m_engine;
|
||||
};
|
||||
|
||||
} /* namespace utils */
|
||||
} /* namespace farmlands */
|
||||
|
||||
#endif /* UTILS_RANDOM_H_ */
|
Reference in New Issue
Block a user