コード例 #1
0
void getKeyboardPress(unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27:
		exit(0);
	case 'w':
		walk_up();
		break;
	case 's':
		walk_down();
		break;
	case 'a':
		//cout << "a";
		walk_left();
		break;
	case 'd':
		walk_right();
		break;
	case 'q':
		turn_left();
		break;
	case 'e':
		turn_right();
		break;
	case 'f':
		if ((CreatFlower == false) && (CreatTree == false))
		{
			Flower* tem = new Flower;
			int temx, temy, temz;
			get_Groung_position(mouse_x, mouse_y, temx, temy, temz);
			tem->setPosition(temx, temz);
			tem->setAlpha(0.35f);
			flower_display_list.push_back(tem);
			CreatFlower = true;
		}
		coutstat();
		break;
	case 't':
		if ((CreatFlower == false) && (CreatTree == false))
		{
			Tree* tem = new Tree;
			int temx, temy, temz;
			get_Groung_position(mouse_x, mouse_y, temx, temy, temz);
			tem->setPosition(temx, temz);
			tree_display_list.push_back(tem);
			CreatTree = true;
		}
		coutstat();
		break;
	case 'z':
		save_all();
		break;
	case 'l':
		load_all();
		break;
	case 'r':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_R(0.1f);
		}
		coutstat();
		break;
	case 'g':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_G(0.1f);
		}
		coutstat();
		break;

	case 'b':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_B(0.1f);
		}
		coutstat();
		break;

	case 'n':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_NUM(1);
		}
		if (CreatTree == true)
		{
			tree_display_list[tree_display_list.size() - 1]->change_tree_level(1);
		}
		coutstat();
		break;

	case 'm':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_NUM(-1);
		}
		if (CreatTree == true)
		{
			tree_display_list[tree_display_list.size() - 1]->change_tree_level(-1);
		}
		coutstat();
		break;

	case 'p':
		is_snow = 1 - is_snow;
		snowcount = 0;
		coutstat();
		break;

	case 'o':
		if (have_wind) stop_wind();
		else start_wind();
		coutstat();
		break;

	case 'i':
		snow_down();
		break;

	case 'j':
		change_snow_level(-5);
		coutstat();
		break;

	case 'k':
		change_snow_level(5);
		coutstat();
		break;
	}

	

}
コード例 #2
0
ファイル: SceneManager.cpp プロジェクト: vanish87/Jungle-of
	bool SceneManager::LoadScene( string file_name )
	{
		cout<<"=========Loading Scene Config================"<<endl;
		ofxXmlSettings file;
		if(!file.loadFile(file_name))
		{
			cout<<"Cannot load "<<file_name<<endl;
			return false;
		}
		if(!file.tagExists("LevelIndex"))
		{
			cout<<"Cannot find LevelIndex"<<endl;
			return false;
		}

        ReadColorSet(file);
        
		file.pushTag("LevelIndex");
		for(size_t i =0; i < file.getNumTags("Level"); ++i)
		{
			vector<string> group_name;
			for(size_t i =0; i < file.getNumTags("Group"); ++i)
			{
				file.pushTag("Group",i);
				string name = file.getValue("Name","NONE");
				group_name.push_back(name);
				file.popTag();
			}
			level_index_.push_back(group_name);
		}
		file.popTag();

		SceneType scene;

		for(size_t i =0; i < file.getNumTags("Group"); ++i)
		{
			file.pushTag("Group",i);
			string name = file.getValue("Name","NONE");
			//if(name == group_name[i])
			{
				string type = file.getValue("Type","NONE");
				if(type == "Flower")
				{
					vector<Flower*> group_model;
					if(file.tagExists("GroupObj"))
					{
						file.pushTag("GroupObj");
						for(size_t j =0; j < file.getNumTags("Model"); ++j)
						{
							file.pushTag("Model",j);
							string url = file.getValue("ObjURL", "NA");
							ofVec3f pos;
							file.pushTag("Position");
							pos.set(file.getValue("X",0), file.getValue("Y",0), file.getValue("Z",0));
							file.popTag();
							float rotation = file.getValue("Rotation",0);
							float max_scale = file.getValue("MaxScale",0.1);
							float scale_speed = file.getValue("ScaleSpeed", 0.01);
							float staying_time = file.getValue("StayingTime", 1);
							float holding_time = file.getValue("HoldingTime", 1);
							float circle_size = file.getValue("CircleSize", 200);
							file.pushTag("CircleColor");
							ofColor color;
							color.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
							file.pushTag("ModelColor");
							ofColor mcolor;
							mcolor.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();


							bool falling = file.getValue("FallingEnable", false);
							float pitch = file.getValue("Pitch", 1.0f);

							Flower* flower = new Flower();
							flower->loadModel(url);
							flower->setPosition(pos.x,pos.y,pos.z);
							flower->setRotation(0,180,1,0,0);
							flower->setRotation(1,rotation,0,0,1);
							flower->SetMaxScale(max_scale);
							flower->SetScaleSpeed(scale_speed);
							flower->staying_time_ = staying_time + ofRandom(-3, 3);
							flower->holding_time_ = holding_time;
							flower->SetCircleSize(circle_size);
							flower->SetCircleColor(color);
							flower->SetColor(mcolor);
							flower->SetFalling(falling);
							flower->SetPitch(pitch);
							flower->Enable(false);
							group_model.push_back(flower);
							file.popTag();
						}
						file.popTag();

						float group_staying_time= file.getValue("StayingTime",1);

						Group flower_group(name, group_staying_time, group_model, Group::LEAF);
						scene.push_back(flower_group);
					}
				}
				else
                if(type == "Mushroom")
                {
                    vector<Flower*> group_model;
					if(file.tagExists("GroupObj"))
					{
						file.pushTag("GroupObj");
						for(size_t j =0; j < file.getNumTags("Model"); ++j)
						{
							file.pushTag("Model",j);
							string url = file.getValue("ObjURL", "NA");
							ofVec3f pos;
							file.pushTag("Position");
							pos.set(file.getValue("X",0), file.getValue("Y",0), file.getValue("Z",0));
							file.popTag();
							float rotation = file.getValue("Rotation",0);
							float max_scale = file.getValue("MaxScale",0.1);
							float scale_speed = file.getValue("ScaleSpeed", 0.01);
							float staying_time = file.getValue("StayingTime", 1);
							float holding_time = file.getValue("HoldingTime", 1);
							float circle_size = file.getValue("CircleSize", 200);
							file.pushTag("CircleColor");
							ofColor color;
							color.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
							file.pushTag("ModelColor");
							ofColor mcolor;
							mcolor.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
                            
                            
							bool falling = file.getValue("FallingEnable", false);
							float pitch = file.getValue("Pitch", 1.0f);
                            
							Mushroom* flower = new Mushroom();
							flower->loadModel(url);
							flower->setPosition(pos.x,pos.y,pos.z);
							flower->setRotation(0,180,1,0,0);
							flower->setRotation(1,rotation,0,0,1);
							flower->SetMaxScale(max_scale);
							flower->SetScaleSpeed(scale_speed);
							flower->staying_time_ = staying_time + ofRandom(-3, 3);
							flower->holding_time_ = holding_time;
							flower->SetCircleSize(circle_size);
							flower->SetCircleColor(color);
							flower->SetColor(mcolor);
							flower->SetFalling(falling);
							flower->SetPitch(pitch);
							flower->Enable(false);
							group_model.push_back(flower);
							file.popTag();
						}
						file.popTag();
                        
						float group_staying_time= file.getValue("StayingTime",1);
                        
						Group flower_group(name, group_staying_time, group_model, Group::MUSHROOM);
						scene.push_back(flower_group);
					}
                }
                else
                if (type == "Fruit")
                {
                    vector<Flower*> group_model;
					if(file.tagExists("GroupObj"))
					{
						file.pushTag("GroupObj");
						for(size_t j =0; j < file.getNumTags("Model"); ++j)
						{
							file.pushTag("Model",j);
							string url = file.getValue("ObjURL", "NA");
							ofVec3f pos;
							file.pushTag("Position");
							pos.set(file.getValue("X",0), file.getValue("Y",0), file.getValue("Z",0));
							file.popTag();
							float rotation = file.getValue("Rotation",0);
							float max_scale = file.getValue("MaxScale",0.1);
							float scale_speed = file.getValue("ScaleSpeed", 0.01);
							float staying_time = file.getValue("StayingTime", 1);
							float holding_time = file.getValue("HoldingTime", 1);
							float circle_size = file.getValue("CircleSize", 200);
							file.pushTag("CircleColor");
							ofColor color;
							color.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
							file.pushTag("ModelColor");
							ofColor mcolor;
							mcolor.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
                            
                            
							bool falling = file.getValue("FallingEnable", false);
							float pitch = file.getValue("Pitch", 1.0f);
                            
							Flower* flower = new Flower();
							flower->loadModel(url);
							flower->setPosition(pos.x,pos.y,pos.z);
							flower->setRotation(0,180,1,0,0);
							flower->setRotation(1,rotation,0,0,1);
							flower->SetMaxScale(max_scale);
							flower->SetScaleSpeed(scale_speed);
							flower->staying_time_ = staying_time + ofRandom(-3, 3);
							flower->holding_time_ = holding_time;
							flower->SetCircleSize(circle_size);
							flower->SetCircleColor(color);
							flower->SetColor(mcolor);
							flower->SetFalling(falling);
							flower->SetPitch(pitch);
							flower->Enable(false);
							group_model.push_back(flower);
							file.popTag();
						}
						file.popTag();
                        
						float group_staying_time= file.getValue("StayingTime",1);
                        
						Group flower_group(name, group_staying_time, group_model, Group::FRUIT);
						scene.push_back(flower_group);
					}

                }
                else
				if(type == "Tree")
				{
					vector<Flower*> group_model;
					if(file.tagExists("GroupObj"))
					{
						file.pushTag("GroupObj");
						for(size_t j =0; j < file.getNumTags("Model"); ++j)
						{
							file.pushTag("Model",j);
							string url = file.getValue("ObjURL", "NA");
							ofVec3f pos;
							file.pushTag("Position");
							pos.set(file.getValue("X",0), file.getValue("Y",0), file.getValue("Z",0));
							file.popTag();
							float rotation = file.getValue("Rotation",0);
							float max_scale = file.getValue("MaxScale",0.1);
							float scale_speed = file.getValue("ScaleSpeed", 0.01);
							float staying_time = file.getValue("StayingTime", 1);
							float holding_time = file.getValue("HoldingTime", 1);
							float circle_size = file.getValue("CircleSize", 200);
							file.pushTag("CircleColor");
							ofColor color;
							color.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();
							file.pushTag("ModelColor");
							ofColor mcolor;
							mcolor.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
							file.popTag();


							bool falling = file.getValue("FallingEnable", false);
							float pitch = file.getValue("Pitch", 1.0f);

							Tree* flower = new Tree();
							flower->loadModel(url);
							flower->setPosition(pos.x,pos.y,pos.z);
							flower->setRotation(0,180,1,0,0);
							flower->setRotation(1,rotation,0,0,1);
                            flower->setScale(0.4, 0.4, 0.4);
							flower->SetMaxScale(max_scale);
							flower->SetScaleSpeed(scale_speed);
							flower->staying_time_ = staying_time + ofRandom(-3, 3);
							flower->holding_time_ = holding_time;
							flower->SetCircleSize(circle_size);
							flower->SetCircleColor(color);
							flower->SetColor(mcolor);
							flower->SetFalling(falling);
							flower->SetPitch(pitch);
							flower->Enable(false);
							group_model.push_back(flower);
							file.popTag();
						}
						file.popTag();

						float group_staying_time= file.getValue("StayingTime",1);

						Group flower_group(name, group_staying_time, group_model, Group::TREE);
						scene.push_back(flower_group);
					}
				}
                else
                    if(type == "Cloud")
                    {
                        vector<Flower*> group_model;
                        if(file.tagExists("GroupObj"))
                        {
                            file.pushTag("GroupObj");
                            for(size_t j =0; j < file.getNumTags("Model"); ++j)
                            {
                                file.pushTag("Model",j);
                                string url = file.getValue("ObjURL", "NA");
                                ofVec3f pos;
                                file.pushTag("Position");
                                pos.set(file.getValue("X",0), file.getValue("Y",0), file.getValue("Z",0));
                                file.popTag();
                                float rotation = file.getValue("Rotation",0);
                                float max_scale = file.getValue("MaxScale",0.1);
                                float scale_speed = file.getValue("ScaleSpeed", 0.01);
                                float staying_time = file.getValue("StayingTime", 1);
                                float holding_time = file.getValue("HoldingTime", 1);
                                float circle_size = file.getValue("CircleSize", 200);
                                file.pushTag("CircleColor");
                                ofColor color;
                                color.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
                                file.popTag();
                                file.pushTag("ModelColor");
                                ofColor mcolor;
                                mcolor.set(file.getValue("R",255), file.getValue("G",255), file.getValue("B",255), file.getValue("A",255));
                                file.popTag();
                                
                                
                                bool falling = file.getValue("FallingEnable", false);
                                float pitch = file.getValue("Pitch", 1.0f);
                                
                                Cloud* flower = new Cloud();
                                flower->loadModel(url);
                                flower->setPosition(pos.x,pos.y,pos.z);
                                flower->setRotation(0,180,1,0,0);
                                flower->setRotation(1,rotation,0,0,1);
                                flower->SetMaxScale(max_scale);
                                flower->SetScaleSpeed(scale_speed);
                                flower->staying_time_ = staying_time + ofRandom(-3, 3);
                                flower->holding_time_ = holding_time;
                                flower->SetCircleSize(circle_size);
                                flower->SetCircleColor(color);
                                flower->SetColor(mcolor);
                                flower->SetFalling(falling);
                                flower->SetPitch(pitch);
								flower->InitDroplet();
                                flower->Enable(false);
                                group_model.push_back(flower);
                                file.popTag();
                            }
                            file.popTag();
                            
                            float group_staying_time= file.getValue("StayingTime",1);
                            
                            Group flower_group(name, group_staying_time, group_model, Group::CLOUD);
                            scene.push_back(flower_group);
                        }
                    }
				

			}
			file.popTag();

			
		}

		dynamic_objects_ =  scene;
		return true;
	}