gameNode::gameNode(int N, int type, double uMean, double uSD) { numU = N; int i = 0; std::vector< double > tempV; std::random_device rd; std::default_random_engine generator(rd()); if(type==1) { // std::gamma_distribution< double > uDist(uMean,uSD); std::normal_distribution<double> uDist(uMean,uSD); for(i=0;i<numU;i++) { tempV.push_back( uDist(generator) ); } u = std::vector< double >(tempV); } else if(type==2) { std::gamma_distribution< double > uDist(uMean,uSD); // std::normal_distribution<double> uDist(uMean,uSD); for(i=0;i<numU;i++) { tempV.push_back( uDist(generator) ); } u = std::vector< double >(tempV); } }
GameTable::GameTable(SDL_Renderer* pRenderer, const Uint32 w, const Uint32 h) { // Game window size windowW = w; windowH = h; // Game table initialization table = new Table(); // Timer initialization Uint32 timerW = 100; Uint32 timerH = 10; Uint32 timerX = static_cast<Uint32>((windowW * 0.5) - (timerW * 0.5f)); Uint32 timerY = 5; timerRect = SDL_Rect{ timerX, timerY, timerW, timerH }; timerFillColor = SDL_Color{ 250, 104, 87, 255 }; timerBGColor = SDL_Color{ 255, 207, 201, 255 }; timer = new SimpleTimer(); animTimer = new SimpleTimer(); // Upper Left position ulPos = new SDL_Point{ 50, 300 }; // Table Rectangle delimiter tableDelimiter = new SDL_Rect{ ulPos->x, ulPos->y - (rowNum - 1) * 40, colLimit * 40, rowNum * 40 }; // Initialize randomization distributionForColumn = uDist(minColNum, rowNum); // At max baseMaxBlockColor colors at first distributionForBlockColor = uDist(0, baseMaxBlockColor); // At first only normal blocks distributionForBlockType = uDist(0, 0); // Random functions // Defining on the fly seed for the random engine auto seed = static_cast<Uint32>(std::chrono::system_clock::now().time_since_epoch().count()); generator = std::default_random_engine(1); // Binding for ease of use randColNum = std::bind(distributionForColumn, generator); randBlockColor = std::bind(distributionForBlockColor, generator); randBlockType = std::bind(distributionForBlockType, generator); // Loading background textures backgroundTexture = new SimpleTexture(pRenderer); backgroundTexture->LoadFromFileRGB(TABLE_BG_TEX_NAME, SDL_FALSE, nullptr); // Loading block textures blockTexture = new SimpleTexture(pRenderer); blockTexture->LoadFromFileRGB(BLOCK_TEX_NAME, SDL_FALSE, nullptr); blockTextureHighlighted = new SimpleTexture(pRenderer); blockTextureHighlighted->LoadFromFileRGB(BLOCK_TEX_HL_NAME, SDL_FALSE, nullptr); // Loading font gameFont = TTF_OpenFont(fontName.c_str(), 20); textTexture = new SimpleTexture(pRenderer); // Creating buttons btnAddFaceTexture = new SimpleTexture(pRenderer); btnAddFaceTexture->LoadFromFileRGB(PLUS_TEX_HL_NAME, SDL_FALSE, nullptr); btnAddColumn = new SimpleButton(pRenderer, blockTexture, blockTextureHighlighted, btnAddFaceTexture, SDL_Color{ 255, 255, 255, 255 }, ulPos->x + ((colLimit - 1) * 40), ulPos->y + 40, 40, 40); btnPauseGame = new SimpleButton(pRenderer, blockTexture, blockTextureHighlighted, nullptr, SDL_Color{ 255, 255, 255, 255 }, ulPos->x - 40 - 5, ulPos->y - ((rowNum - 1) * 40), 40, 40); // Initialize Linked block lists blockLinks = LinkList(); newLink = new Link(); // Score, experience and pause rendering settings scoreColor = SDL_Color{ 0xFF, 0xE4, 0xD1, 0xFF }; scoreULPos = SDL_Point{ 100, static_cast<Uint32>(windowH * 0.8f) }; levelULPos = SDL_Point{ 100, static_cast<Uint32>(windowH * 0.8f) + 30 }; // Calculate pause string width int* posW = new int(); int* posH = new int(); TTF_SizeText(gameFont, pauseText.c_str(), posW, posH); auto textSize = *posW; pauseULPos = SDL_Point{ static_cast<Uint32>((windowW - textSize) * 0.5f), static_cast<Uint32>(windowH * 0.5f - 100) }; // Calculate experience string width TTF_SizeText(gameFont, expText.c_str(), posW, posH); textSize = *posW; expULPos = SDL_Point{ static_cast<Uint32>((windowW - textSize) * 0.5f), ulPos->y + 35 }; expRect = SDL_Rect{ static_cast<Uint32>(windowW * 0.5f - 100), expULPos.y + *posH + 5, 200, 15 }; delete posW; delete posH; // Initialize all the game variables Init(); }