diff --git a/NothinFancy/src/Engine.cpp b/NothinFancy/src/Engine.cpp index cb74e67..9ddcb33 100644 --- a/NothinFancy/src/Engine.cpp +++ b/NothinFancy/src/Engine.cpp @@ -16,11 +16,8 @@ namespace nf { SetThreadDescription(GetCurrentThread(), L"NF Main Thread"); SetConsoleTitle(std::format("{} Debug Console - {}", engineStr, gameStr).c_str()); #endif - { - NFTime(); - std::this_thread::sleep_for(std::chrono::seconds(1)); - NFLog("Test!"); - } + for (int i = 0; i < 10; i++) + NFLog(util::getRandRange(3, 5)); std::cin.get(); } diff --git a/NothinFancy/src/util.h b/NothinFancy/src/util.h index 38ec996..8541c38 100644 --- a/NothinFancy/src/util.h +++ b/NothinFancy/src/util.h @@ -3,6 +3,7 @@ #include "util/log.h" +// Define NFTime #ifdef _DEBUG #define NFTime() ::nf::util::ScopedTimer __scopeTimer(__FUNCSIG__) #else @@ -10,6 +11,9 @@ #endif namespace nf::util { + double getRand(); + double getRandRange(double minimum, double maximum); + class ScopedTimer { public: ScopedTimer(const char* funcName); diff --git a/NothinFancy/src/util/log.cpp b/NothinFancy/src/util/log.cpp index 6e740d8..a1e8e5c 100644 --- a/NothinFancy/src/util/log.cpp +++ b/NothinFancy/src/util/log.cpp @@ -37,7 +37,7 @@ namespace nf::util { auto time = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - s_initTime); - std::cout << std::format("[{:9.3f}] NF {}: {}\n", time.count() * 1e-3, s_logTypesMap[type], msg); + std::cout << std::format("[{:9.3f}][NF {}]:\t{}\n", time.count() * 1e-3, s_logTypesMap[type], msg); } void log(const std::string& msg, LogType type) { diff --git a/NothinFancy/src/util/util.cpp b/NothinFancy/src/util/util.cpp index ef34527..337d42d 100644 --- a/NothinFancy/src/util/util.cpp +++ b/NothinFancy/src/util/util.cpp @@ -3,7 +3,18 @@ #include "util.h" +#undef max + namespace nf::util { + double getRand() { + static std::random_device dev; + return static_cast(dev()) / dev.max(); + } + + double getRandRange(double minimum, double maximum) { + return getRand() * (maximum - minimum) + minimum; + } + ScopedTimer::ScopedTimer(const char* funcName) : m_funcName(funcName) , m_startTime(std::chrono::high_resolution_clock::now())