void GameView::OnShow() { m_gameover = false; InitPhysics(Vector2::Zero, 1.f); // Create the main game node. Map + objects go in there and are affected by light m_pGameLayer = CreateLightLayer(); m_pGameLayer->SetAmbient(Color(.10f, .15f, .2f, 1)); // Set that so something cool jason will decide on AddNode(m_pGameLayer); // spawn players from the lobby data, for now assume one CreateMusic(); CreateTileMap(); GenerateMap(); CreateEntities(); CenterCamera(); SpawnPlayers(); CreatePathFinder(); m_fadeQuad = CreateSprite("healthGaugeFill.png"); m_fadeQuad->GetColorAnim().start(Color(0.f, 0.f, 0.f, 1.f), Color(0.f, 0.f, 0.f, 0.f), 3.f); m_fadeQuad->SetFilter(onut::SpriteBatch::eFiltering::Nearest); m_fadeQuad->SetScale(Vector2(100, 100)); AddNode(m_fadeQuad); }
void TestSparsePerformance(bool outputMap) { int cellSize = 16; int w = 40; int h = 100; double map = CreateSparseMap(w*cellSize,h*cellSize,cellSize); //map = CreateMap(w*cellSize,h*cellSize,cellSize); SetCellMap(map, 4*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 5*cellSize, 1); SetCellMap(map, 5*cellSize, 6*cellSize, 1); SetCellMap(map, 5*cellSize, 7*cellSize, 1); SetCellMap(map, 4*cellSize, 7*cellSize, 1); SetCellMapRegion(map, (w/2)*cellSize, 0*cellSize, 2*cellSize, (h*0.75)*cellSize, 1); //SetCellMapRegion(map, (w/2)*cellSize, (h/2+1)*cellSize, 2*cellSize, (h/2-2)*cellSize, 1); #ifndef _DEBUG double pathFinder = CreatePathFinder(map); #else double mapDebug = CreateMap(w*cellSize,h*cellSize,cellSize); double pathFinder = CreatePathFinderDebug(map, mapDebug); #endif double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, (w-2)*cellSize, 2.0*cellSize); if (outputMap) { OutputPath(map, path); } DestroyMap(map); DestroyPathFinder(pathFinder); DestroyPath(path); #ifdef _DEBUG DestroyMap(mapDebug); #endif }
double GenPathFinder(double map, int w, int h, int cellSize) { #ifndef _DEBUG double pathFinder = CreatePathFinder(map); #else double mapDebug = CreateMap(w*cellSize,h*cellSize,cellSize); double pathFinder = CreatePathFinderDebug(map, mapDebug); #endif return pathFinder; }
void TestGmInterface() { int cellSize = 10; double map = CreateMap(10*cellSize,10*cellSize,cellSize); SetCellMap(map, 4*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 4*cellSize, 1); SetCellMap(map, 5*cellSize, 5*cellSize, 1); SetCellMap(map, 5*cellSize, 6*cellSize, 1); SetCellMap(map, 5*cellSize, 7*cellSize, 1); SetCellMap(map, 4*cellSize, 7*cellSize, 1); double pathFinder = CreatePathFinder(map); double path = FindPath(pathFinder, 2.0*cellSize, 8.0*cellSize, 8.0*cellSize, 3.0*cellSize); double n = static_cast<int>(GetNPath(path)); DestroyMap(map); DestroyPathFinder(pathFinder); DestroyPath(path); }