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


C++ Plane::SetOrigin方法代码示例

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


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

示例1: ProcessControls


//.........这里部分代码省略.........
		float accelerating = lengine->GetScale().x;
	
		if(keys[SDLK_RIGHT]) // If the right arrow key is pressed
		{
			ship->Rotate(glm::vec3(0.0f,0.0f,+rotSpeed));			// Rotate the ship clockwise
		}
	
		if(keys[SDLK_LEFT]) // If the right arrow key is pressed
		{
			ship->Rotate(glm::vec3(0.0f,0.0f,-rotSpeed));									// Rotate the ship clockwise
		}

		if(keys['w'])
		{
			if(magnitude > -maxspeed)	// If the throttle is less than max
			{
				vel += 0.5f*dir*acceleration;
			}
			else
			{
				vel -= maxspeed;
			}

			if(accelerating < 1.0f)
				accelerating += .05f;
			else
				accelerating = 1.0f;
		}
		else
		{
			if(accelerating > 0)
				accelerating -= .05f;
			else
				accelerating = 0.0f;
		}

		if(vel.x > 0 && vel.x < 0.1f)	// If the throttle is close to zero
		{
			vel.x=0;											// Go ahead and set it to zero (no need to waste fuel)
		}
		if(vel.y > 0 && vel.y < 0.1f)	// If the throttle is close to zero
		{
			vel.y=0;											// Go ahead and set it to zero (no need to waste fuel)
		}
		
		if(vel.x < 0 && vel.x > -0.1f)	// If the throttle is close to zero
		{
			vel.x=0;											// Go ahead and set it to zero (no need to waste fuel)
		}
		if(vel.y < 0 && vel.y > -0.1f)	// If the throttle is close to zero
		{
			vel.y=0;											// Go ahead and set it to zero (no need to waste fuel)
		}
		
		glm::vec3 pos = ship->GetPosition();
		
		if(pos.x > WM->GetWindowWidth()+16.0f)
		{
			pos.x = -16.0f;
			ship->SetPosition(pos);
		}
		else if(pos.x < -16.0f)
		{
			pos.x = WM->GetWindowWidth()+16.0f;
			ship->SetPosition(pos);
		}

		if(pos.y > WM->GetWindowHeight()+16.0f)
		{
			pos.y = -16.0f;
			ship->SetPosition(pos);
		}
		else if(pos.y < -16.0f)
		{
			pos.y = WM->GetWindowHeight()+16.0f;
			ship->SetPosition(pos);
		}

		ship->SetThrottle(vel);
		ship->Translate(vel);
		pos = ship->GetPosition();

		glm::vec3 rot = glm::vec3(0,0,-(atan2(mouse_x-pos.x,mouse_y-pos.y)+3.14159)*180/3.14159);
		ship->SetRotation(rot);

		if(!lengine || !rengine)
			return;
		lengine->SetOrigin(-50,0);
		lengine->SetPosition(pos);
		lengine->SetRotation(rot);
		float lscalemod = rand()%10/100.0f-0.05f;
		float rscalemod = rand()%10/100.0f-0.05f;
		glm::vec3 lscale = glm::vec3(accelerating+lscalemod,accelerating+lscalemod,accelerating+lscalemod);
		glm::vec3 rscale = glm::vec3(accelerating+rscalemod,accelerating+rscalemod,accelerating+rscalemod);
		lengine->SetScale(lscale);
		rengine->SetScale(rscale);
		rengine->SetPosition(pos);
		rengine->SetRotation(rot);
	}
}
开发者ID:Rocks25,项目名称:Voa,代码行数:101,代码来源:PlayerController.cpp


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