Call std::srand() at the beginning.
This commit is contained in:
parent
2a4ae78374
commit
bf8d9ea327
2 changed files with 12 additions and 4 deletions
|
@ -28,6 +28,7 @@
|
||||||
#define REFERENCE_HEIGHT 600
|
#define REFERENCE_HEIGHT 600
|
||||||
#define DEF_WIN_WIDTH REFERENCE_WIDTH
|
#define DEF_WIN_WIDTH REFERENCE_WIDTH
|
||||||
#define DEF_WIN_HEIGHT REFERENCE_HEIGHT
|
#define DEF_WIN_HEIGHT REFERENCE_HEIGHT
|
||||||
|
#define DEF_RANDOM_SEED 1984
|
||||||
|
|
||||||
#define GAME_BASE_PATH "@CMAKE_SOURCE_DIR@"
|
#define GAME_BASE_PATH "@CMAKE_SOURCE_DIR@"
|
||||||
|
|
||||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -25,10 +25,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
///-------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
///-------------------------------------------------------------------------
|
///--------------------------------------------------------------------------
|
||||||
void RunMainLoop (cloonel::GameplaySceneClassic& parGame) {
|
void RunMainLoop (cloonel::GameplaySceneClassic& parGame) {
|
||||||
parGame.Prepare();
|
parGame.Prepare();
|
||||||
do {
|
do {
|
||||||
|
@ -38,10 +40,15 @@ namespace {
|
||||||
}
|
}
|
||||||
} //unnamed namespace
|
} //unnamed namespace
|
||||||
|
|
||||||
///----------------------------------------------------------------------------
|
///------------------------------------------------------------------------------
|
||||||
///following http://twinklebeardev.blogspot.co.uk/2012/07/lesson-1-hello-world.html
|
///following http://twinklebeardev.blogspot.co.uk/2012/07/lesson-1-hello-world.html
|
||||||
///----------------------------------------------------------------------------
|
///------------------------------------------------------------------------------
|
||||||
int main (int, char* parArgv[]) {
|
int main (int, char* parArgv[]) {
|
||||||
|
#if defined(NDEBUG)
|
||||||
|
std::srand(static_cast<unsigned int>(std::time(nullptr)));
|
||||||
|
#else
|
||||||
|
std::srand(static_cast<unsigned int>(DEF_RANDOM_SEED));
|
||||||
|
#endif
|
||||||
std::cout << GameName << " v" << GameVersionMajor << "." << GameVersionMinor << std::endl;
|
std::cout << GameName << " v" << GameVersionMajor << "." << GameVersionMinor << std::endl;
|
||||||
|
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
Loading…
Reference in a new issue