当前位置: 首页>>代码示例>>C++>>正文


C++ Play::Draw方法代码示例

本文整理汇总了C++中Play::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Play::Draw方法的具体用法?C++ Play::Draw怎么用?C++ Play::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Play的用法示例。


在下文中一共展示了Play::Draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WinMain

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	ChangeWindowMode(true);
	SetGraphMode(640, 480, 16);
	DxLib_Init();
	SetDrawScreen(DX_SCREEN_BACK);
	SetDrawMode(DX_DRAWMODE_BILINEAR);
	SetMainWindowText("禁断の果実と楽園の護人");

	//int titlebg = LoadGraph("picture/taitol.bmp");
	int titletext = LoadGraph("picture/title.bmp");
	int bg = LoadGraph("picture/playbg_2.bmp");
	int tree = LoadGraph("picture/bigtreekai.bmp");
	char key[256];
	Opening openingscene;
	Play playscene;
	MusicSelect musicselect;
	Result resultscene;

	enum{
		OPENING,
		PLAY,
		MUSICSELECT,
		RESULT
	}scene=OPENING;

	while(Process(key)){
		switch(scene){
		case OPENING:
			DrawGraph(0, 0, bg, false);
			DrawGraph(0, 0, tree, true);
			DrawGraph(0, 0, titletext, true);
			if( ProcessMessage() == -1 ){
				break ;        // エラーが起きたらループを抜ける
			}
			openingscene.UpDate();
			openingscene.Draw();
			if(key[KEY_INPUT_LEFT]==1 || openingscene.HitJudge() == true){
				scene = MUSICSELECT;
				
			}

			if(key[KEY_INPUT_ESCAPE]==1){
				DxLib_End();
			}
			break;

		case MUSICSELECT:
			if( ProcessMessage() == -1 ){
				break ;        // エラーが起きたらループを抜ける
			}
			DrawGraph(0, 0, bg, false);
			DrawGraph(0, 0, tree, true);
			musicselect.UpDate();
			musicselect.Draw();
			if(musicselect.HitJudge() == true){
				playscene.Loadfile(musicselect.GetMusicfile());
				playscene.SetMusic(musicselect.GetMusic());
				playscene.SoundPlay();
				scene = PLAY;
			}
			if(key[KEY_INPUT_UP]==1){
				scene = PLAY;
			}

			if(key[KEY_INPUT_ESCAPE]==1){
				DxLib_End();
			}
			break;

		case PLAY:
			if( ProcessMessage() == -1 ){
				break ;        // エラーが起きたらループを抜ける
			}
			DrawGraph(0, 0, bg, false);
			DrawGraph(0, 0, tree, true);
			playscene.UpDate();
			playscene.Draw();
			if(key[KEY_INPUT_RIGHT]==1 || playscene.isPlaying() == false){
				playscene.SoundStop();
				scene = RESULT;
			}

			if(key[KEY_INPUT_ESCAPE]==1){
				DxLib_End();
			}
			break;
		
		case RESULT:
			DrawGraph(0, 0,bg, false);
			resultscene.Update();
			resultscene.Draw();
			if(key[KEY_INPUT_DOWN]==1 || resultscene.HitJudge() == true){
				scene = OPENING;
			}

			if(key[KEY_INPUT_ESCAPE]==1){
				DxLib_End();
			}
			break;
//.........这里部分代码省略.........
开发者ID:Butanosuke,项目名称:Kikori,代码行数:101,代码来源:Main.cpp

示例2: main


//.........这里部分代码省略.........
	//Flock flock;
	//vector<sf::CircleShape> shapes;

	//for (int i = 0; i < 25; i++) //Number of boids is hardcoded for testing pusposes.
	//{
	//	//Boid b(rand() % window_width, rand() % window_height); //Starts the boid with a random position in the window.
	//	Boid b((window_width * 3) / 2, (window_height * 3) / 2 -150); //Starts all boids in the center of the screen
	//	sf::CircleShape shape(boidsSize, 3); //Shape with a radius of 10 and 3 points (Making it a triangle)

	//	//Changing the Visual Properties of the shape
	//	//shape.setPosition(b.location.x, b.location.y); //Sets position of shape to random location that boid was set to.
	//	shape.setPosition(window_width, window_height); //Testing purposes, starts all shapes in the center of screen.
	//	shape.setOutlineColor(sf::Color(0, 255, 0));
	//	shape.setFillColor(sf::Color::Green);
	//	shape.setOutlineColor(sf::Color::White);
	//	shape.setOutlineThickness(1);
	//	shape.setRadius(boidsSize);

	//	//Adding the boid to the flock and adding the shapes to the vector<sf::CircleShape>
	//	flock.addBoid(b);
	//	shapes.push_back(shape);
	//	
	//}

	menu = new Menu(window_width, window_height);
	play = new Play(window_width, window_height);


	////create a circle
	//sf::CircleShape circle(50);
	//
	//sf::CircleShape circle2(100);

	sf::Time time;
	sf::Clock m_clock;

	// Start game loop 
	while (window.isOpen())
	{
		// Process events 
		sf::Event Event;
		while (window.pollEvent(Event))
		{
			// Close window : exit 
			if (Event.type == sf::Event::Closed)
				window.close();
		}

		time = m_clock.getElapsedTime();
		float t = time.asSeconds();
		m_clock.restart();


		//updates
		switch (StateController::GetInstance()->getState())
		{
		case StateController::MENU:
			menu->Update(t);
			break;
		case StateController::PLAY:
			play->Update(t, window);
			break;
		case StateController::CREDITS:
			break;
		case StateController::PAUSE:
			break;
		case StateController::SPLASH:
			break;
		case StateController::SCORESCREEN:
			break;
		}//end switch


		window.clear();
		
		//draw
		switch (StateController::GetInstance()->getState())
		{
		case StateController::MENU:
			menu->Draw(window);
			break;
		case StateController::PLAY:
			play->Draw(window);
			break;
		case StateController::CREDITS:
			break;
		case StateController::PAUSE:
			break;
		case StateController::SPLASH:
			break;
		case StateController::SCORESCREEN:
			break;
		}//end switch

		
		window.display(); //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>DRAW WINDOW
	} //loop back for next frame
	
	return EXIT_SUCCESS;
}
开发者ID:Bojam1,项目名称:AI_Asteroids,代码行数:101,代码来源:FirstSFMLProject.cpp


注:本文中的Play::Draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。