void Environment::InitializeObstacles(double firstLimit, double lastLimit) { //obstacles.clear(); double lastZ=firstLimit; while(firstLimit<lastLimit) { double type = rand() % 48 + 1; Point3D initialPoint; initialPoint.x = GetRandomGLfloat(0.0, 1.0); initialPoint.z = lastZ+ 0.9; switch((int)sqrt(type)) { case 1: { //if((int)type%2==0) //{ // Point3D p1=road->GetOnRoadPosition(Point3D(-1, 0, initialPoint.z), 0.0); // Point3D p2=road->GetOnRoadPosition(Point3D(-1, 0, initialPoint.z+0.3), 0.0); // Point3D p3=road->GetOnRoadPosition(Point3D(1, 0, initialPoint.z+0.3), 0.0); // Point3D p4=road->GetOnRoadPosition(Point3D(1, 0, initialPoint.z), 0.0); // Hole* hole=new Hole(mario, p1, p2, p3, p4); // lastZ=initialPoint.z+0.4; // scene->AddObject(hole); // road->AddRoadObject(hole); // //obstacles.push_back(hole); // std::ofstream outfile; // outfile.open("HoleCoordinates.cpp", std::ios_base::app); // outfile << initialPoint<<" "<<count<<endl; // outfile.close(); //} break; } case 2: { InitializeRandomBlocks(lastZ); break; } case 3: { if((int)type%2==0) { Goomba* goomba=new Goomba(); goomba->SetTarget(mario); Point3D currentPosition=road->GetOnRoadPosition(initialPoint, goomba->width); goomba->Translate(currentPosition); lastZ=initialPoint.z+goomba->length/20.0; road->AddRoadObject(goomba); scene->AddObject(goomba); //obstacles.push_back(goomba); break; } } case 4: { InitializeCoins(lastZ); break; } case 5: { GLfloat size=5.0; SplitBox* splitBox=new SplitBox(size, 5, size); splitBox->AddCollider(); Point3D currentPosition=road->GetOnRoadPosition(initialPoint, splitBox->width); splitBox->Translate(currentPosition); lastZ = initialPoint.z+splitBox->length/20.0; road->AddRoadObject(splitBox); scene->AddObject(splitBox); std::ofstream outfile; outfile.open("SplitBoxCoordinates.cpp", std::ios_base::app); outfile << initialPoint<<" "<<count<<endl; outfile.close(); //obstacles.push_back(splitBox); break; } case 6: { AddQuestionBlock(initialPoint, lastZ); if(initialPoint.x-5.0/20 > -1.0) { initialPoint.x-=5.0/20; AddQuestionBlock(initialPoint, lastZ); } break; } } firstLimit=lastZ; } }
ChangeMaker::ChangeMaker() { InitializeCoins(); memo_.resize(coins_.size(), std::vector<ll>(10000 + 1, -1)); }