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


C++ CSprite::GetPosition方法代码示例

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


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

示例1: Init

	// Initializare
	void Init(CSprite *spr)
	{
		m_Sprite = spr;

		glm::vec3 pz = m_Sprite->GetPosition();
		m_Sprite->PlayAnimation("BugEye_Idle");

	}
开发者ID:BiancaTud,项目名称:Ubisoft,代码行数:9,代码来源:Main.cpp

示例2: Update

	//update proiectile inamici
	void Update(float dt, int &nr)
	{	
		glm::vec3 posProj;
		iSecret = rand() % 500 + 1;
		if ((int)(dt+iSecret) % 200 == 0 && enemy_projectiles.size()<4){
			enemy_projectiles.push_back(CSpriteManager::Get()->AddSprite("bugproj.png", enemy_proj));
			enemy_projectiles[enemy_projectiles.size() - 1]->
				SetPosition(glm::vec3(m_Sprite->GetPosition().x+0.235f, m_Sprite->GetPosition().y - 0.2f, -13));
		}

		int pivot = 0;
		
		for (int i = 0; i < enemy_projectiles.size(); i++){

			//daca depasesc ecranul sunt sterse
			
			if (enemy_projectiles[i]->GetPosition().y < SCREEN_BOTTOM + 0.5f)
			{

				CSpriteManager::Get()->RemoveSprite(enemy_projectiles[i]->index-pivot-nr);
				enemy_projectiles.erase(enemy_projectiles.begin() + i-pivot);
				nr++;
				pivot++;
			}

			//altfel este updatata pozitia lor
			else{

				posProj = enemy_projectiles[i]->GetPosition();
				enemy_projectiles[i]->SetPosition(glm::vec3(posProj.x,
					posProj.y - dt*enemy_projectiles[i]->speed, posProj.z));
			}
			
		}
		

	}
开发者ID:BiancaTud,项目名称:Ubisoft,代码行数:38,代码来源:Main.cpp

示例3: main


//.........这里部分代码省略.........
	float t = 0.0f;
	float dt = 0.01f;

	float prevTime =(float) glfwGetTime();
	float accumulator = 0.0f;

	Collision *collide = new Collision();
	

	bool hit = false;
	bool hit2 = false;
	int i;
	while (!glfwWindowShouldClose(window))
	{

		_update_fps_counter(window);

		float newTime =(float) glfwGetTime();
		float deltaTime = (float)(newTime - prevTime);
		

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glViewport(0, 0, g_gl_width, g_gl_height);


		if (deltaTime > 0.25f)
			deltaTime = 0.25f;
		prevTime = newTime;

		accumulator += deltaTime;

		while (accumulator >= dt)
		{
			// update logic pentru player
			PlayerEntity.Update(dt);

			// update animatie
			CSpriteManager::Get()->Update(dt);

			//update enemies
			int nr = 0;
			for (int i = 0; i < number_of_enemy; i++)
			{
				if (enemies[i]->life>0){
					vec[i].Update(dt, nr);
				}
			}
			t += dt;
			accumulator -= dt;
		}

		// desenare
		CSpriteManager::Get()->Draw();

		//verificare coliziune intre player si inamic
		for ( i = 0; i< number_of_enemy; i++)
		{
			collide->ResolveCollisionPlayer(playerSprite,enemies[i]);
			if (collide->getStatusPlayer() == true){
				if (playerSprite->life>=0){
					CSpriteManager::Get()->RemoveSprite(lives[lives.size() - 1]->index);
					lives.erase(lives.end() - 1);
				}
				

			}



			//verificare coliziune intre player si proiectile inamici
			vec[i].Collide(playerSprite, collide);

			if (playerSprite->life == 0){
				playerSprite->SetPosition(glm::vec3(-5.0f, -5.0f, playerSprite->GetPosition().z));
			}

			if (enemies[i]->life == 0){
				enemies[i]->life = 2;
			}

		}


		//verificare coliziune intre inamic si proiectilul player-ului
		collide->ResolveCollisionEnemy(CSpriteManager::Get()->projectiles, enemies );

		glfwPollEvents();
		glfwSwapBuffers(window);

		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE))
		{
			glfwSetWindowShouldClose(window, 1);
		}

	}

	delete collide;
	glfwTerminate();
	return 0;
}
开发者ID:BiancaTud,项目名称:Ubisoft,代码行数:101,代码来源:Main.cpp

示例4: Exec

//=============================================================================
//処理
//=============================================================================
//[input]
//	pScene:設定するシーン
//=============================================================================
void CScene::Exec(CScene *pScene)
{
	Renderer::IRender *pRender = pScene->GetAppDevice()->GetRenderer();
	
	CSprite *pSpr = dynamic_cast<CSprite *>( m_p2DObj->FindObjectFromName("Loading") );
	
	pSpr->SetDivnum( Math::Point2DI(6, 1) );
	
	pScene->GetAppDevice()->GetRenderer()->Clear();
	
	pScene->GetAppDevice()->GetRenderer()->Begin();
	
	pSpr->Rendering();
	
	//pScene->GetAppDevice()->GetRenderer()->DebugPrint( Math::Point2DI( 400, 300 ), CColor(255, 255, 255 ), "Npw Loading" );
	
	pScene->GetAppDevice()->GetRenderer()->End();

	pSpr->DrawAnimation( 6, 0 );
	
	/*ロード終わってない*/
	if( !pScene->GetLoadEndFlag() )
	{	
		static string Str = "Now Loading";
		
		static int count = 0;
		
		count ++;
		
		if( count % 10 == 0 )
		{
			Str += ".";
		}
		
		if( count >= 40 )
		{
			count = 0;
			Str = "Now Loading";
		}
		
		pRender->DrawText( Math::Point2DI( 590, 520 ), CColor(255, 255, 255 ), Str.c_str() );
		
		
	}
	
	/*ロード終了*/
	if( pScene->GetLoadEndFlag() )
	{
		pSpr->SetVisibleFlag( false );
		
		m_p3DObj->Init();
		
		CCamera *objCamMain	= dynamic_cast<CCamera *>( m_pGameObj->FindObjectFromName("CamMain") );
		
		objCamMain->Init();
		
		pSpr->Move();
		
		/*キャラが画面外にいったら、次のシーンに*/
		if( pSpr->GetPosition().x <= -100 )
		{
			#if defined( DEBUG_MAP_EDIT ) 
			
				m_eNextScene = SCENE_GAMEMAIN;
			
			
			#elif defined( DEBUG_MAP_SEE )
			
				m_eNextScene = SCENE_DEMO;
				
			#elif defined( DEBUG_CHAT )
			
				m_eNextScene = SCENE_CHAT;
				
			#endif
			
			pScene->SetSceneState( STATE_STANDBY );
			
			pScene->ChangeScene( m_eNextScene );
		}
		
	}
	
}
开发者ID:Taka03,项目名称:Camerun,代码行数:90,代码来源:Scene.cpp


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