coordinate levelMap::setup(int x_size, int y_size, int roomCount){ number_of_rooms =(roomCount); x_dim = x_size; y_dim = y_size; Map = new Cell*[ y_size ]; for(int y= 0; y < y_size; y++){ Map[y] = new Cell[ x_size ]; for(int x = 0; x < x_size; x++){ Map[y][x].Floor = 0x000; } } return (levelGen()); }
void Level::BuildObjectsFromLevelLayout(MainCharacter* mainCharacter) { // Generate parameters and layout LevelLayoutGenerator::Parameters params; if (IsUnderGround() == false) { params.LevelHeight = 12; params.LevelWidth = 256; params.PlatformLenghtRange[0] = 6; params.PlatformLenghtRange[1] = 16; params.IsUnderGround = false; } else { params.LevelHeight = 12; params.LevelWidth = 256; params.PlatformLenghtRange[0] = 4; params.PlatformLenghtRange[1] = 12; params.IsUnderGround = true; } LevelLayoutGenerator levelGen(params); LevelLayout level = levelGen.GenerateLevel(); auto it = level.m_platforms.begin(); auto endit = level.m_platforms.end(); float currentXPosition = 0; int startHack = 0; for (; it < endit; ++it) { float platformLength = it->Length; float platformHeight = it->Height*0.5f+2.0f; if (it->Type == PlatformInfo::E_Canyon) { Object* platform = new PlatformCanyon(glm::vec4(currentXPosition + platformLength / 2.0f, platformHeight - 8, 0, 0)*0.5f, glm::vec4(platformLength*0.5f, 0.5f, 1, 1)); ((GamePlayObject*)platform)->Init(); m_objectList.push_back(platform); } else if (it->Type == PlatformInfo::E_Ruins) { Object* platform = new PlatformRuins(glm::vec4(currentXPosition + platformLength / 2.0f, platformHeight - 8, 0, 0)*0.5f, glm::vec4(platformLength*0.5f, 0.5f, 1, 1)); ((GamePlayObject*)platform)->Init(); m_objectList.push_back(platform); } else if (it->Type == PlatformInfo::E_Bridge) { Object* platform = new PlatformBridge(glm::vec4(currentXPosition + platformLength / 2.0f, platformHeight - 8, 0, 0)*0.5f, glm::vec4(platformLength*0.5f, 0.5f, 1, 1)); ((GamePlayObject*)platform)->Init(); m_objectList.push_back(platform); } else if (it->Type == PlatformInfo::E_Jump && mainCharacter->GetIsAtStartLevel()) { if(mainCharacter->GetCharacterState()!=GamePlayObject::Normal && ((startHack < 2 && !IsUnderGround()) || (startHack < 3 && IsUnderGround()))) { float jumpHeight; if(it == level.m_platforms.begin()) { jumpHeight = (it+1)->Height*0.5f+2.0f; } else { jumpHeight = (it-1)->Height*0.5f+2.0f; } if (!IsUnderGround()) { Object* platform = new PlatformCanyon(glm::vec4(currentXPosition + platformLength / 2.0f, jumpHeight - 8, 0, 0)*0.5f, glm::vec4(platformLength*0.5f, 0.5f, 1, 1)); ((GamePlayObject*)platform)->Init(); m_objectList.push_back(platform); } else { Object* platform = new PlatformRuins(glm::vec4(currentXPosition + platformLength / 2.0f, jumpHeight - 8, 0, 0)*0.5f, glm::vec4(platformLength*0.5f, 0.5f, 1, 1)); ((GamePlayObject*)platform)->Init(); m_objectList.push_back(platform); } startHack++; } else { mainCharacter->SetIsAtStartLevel(false); } } currentXPosition += platformLength; } }
void addVal(struct skipList *list, TYPE val) { addValTest(list, val, levelGen(list)); }