void newMatch(void) { buildMaze(glmaze, Graph_Space, tileSpace, Tilesize, Resources_Manager.texture("wall.tga"), Resources_Manager.texture("floor.tga"), Resources_Manager.texture("ceil.tga"), &Config_Info); restartMatch(); }
void restartMatch(void) { gettimeofday(&Initial_Timer, NULL); MatrixCoord startGraphCoord = MatrixCoord(0, 0); MatrixCoord goalGraphCoord = MatrixCoord(Graph_Space.size().x-1, Graph_Space.size().y-1); for (unsigned int i=0; i<Player_List.size(); ++i) { if (Player_List[i]) { delete Player_List[i]; } } Player_List.clear(); Player_List = std::vector<PlayerBase*>(Config_Info.playerConfigs.size()); float runSpeed = 0.2f; for (unsigned int i=0; i<Config_Info.playerConfigs.size(); ++i) { if (Config_Info.playerConfigs[i].type == HUMAN) { human = new Human(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed, startGraphCoord, goalGraphCoord, Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"), glmaze.aabb, Tilesize); Player_List[i] = human; humanIndex = i; } else if (Config_Info.playerConfigs[i].type == AI_DFS) { Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed, Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"), randomDFSPath(Graph_Space, startGraphCoord, goalGraphCoord), Tilesize); } else if (Config_Info.playerConfigs[i].type == AI_SMART) { Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed, Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"), smartEnhancePath(randomDFSPath(Graph_Space, startGraphCoord, goalGraphCoord)), Tilesize); } else if (Config_Info.playerConfigs[i].type == AI_DUMB) { Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed, Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"), dumbPath(Graph_Space, startGraphCoord, goalGraphCoord), Tilesize); } } finishedPlayers = std::vector<int>(Config_Info.playerConfigs.size(), 0); glm::vec3 startcone = tileSpaceToWorldSpace(MatrixCoord(1,1), Tilesize, Tilesize/2.0f); glm::vec3 endcone = tileSpaceToWorldSpace(tileSpace.size()-MatrixCoord(2,2), Tilesize, Tilesize/2.0f); cone1 = Cone(Resources_Manager.mesh("cone.obj"), Resources_Manager.texture("startmark.tga"), startcone); cone2 = Cone(Resources_Manager.mesh("cone.obj"), Resources_Manager.texture("finishmark.tga"), endcone); winners.clear(); toggleCameraButton->show = false; Camera_Mode = humanIndex; }
void loadResources(Resources *resources) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glEnable(GL_TEXTURE_2D); initAL(resources); std::string font_path; search_path("FreeMonoBold.ttf", font_path); font = new FTGLBitmapFont(font_path.c_str()); Fontbig = new FTGLBitmapFont(font_path.c_str()); if (font->Error()) { DEBUG_ERROR("error on font"); } font->FaceSize(18); if (Fontbig->Error()) { DEBUG_ERROR("error on font"); } Fontbig->FaceSize(110); restartButton = new Button(10, 10, 100, 50, Resources_Manager.texture("restart_button.tga"), restartMatch); newMazeButton = new Button(10, 10, 100, 50, Resources_Manager.texture("newmaze_button.tga"), newMatch); toggleCameraButton = new Button(10, 10, 100, 50, Resources_Manager.texture("togglecamera_button.tga"), toggleCameraMode); Widget_List.push_back(restartButton); Widget_List.push_back(newMazeButton); Widget_List.push_back(toggleCameraButton); skybox.setTexture(Resources_Manager.texture("checkerboard.tga")); skybox.build(Config_Info.matrixDimensions.x*Tilesize*20.0f); }