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


C++ SetAngle函数代码示例

本文整理汇总了C++中SetAngle函数的典型用法代码示例。如果您正苦于以下问题:C++ SetAngle函数的具体用法?C++ SetAngle怎么用?C++ SetAngle使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: GetAngle

void Player::MoveToDestAngle()
{
	float beginangle = GetAngle();
	if (beginangle > 0)
		beginangle = fmodf(beginangle, 2.f*D3DX_PI);
	else
		beginangle = fmodf(beginangle, -2.f*D3DX_PI);

	float deltaangle = destangle - beginangle;
	if (deltaangle > D3DX_PI)
		deltaangle -= 2.f*D3DX_PI;
	if (deltaangle < -D3DX_PI)
		deltaangle += 2.f*D3DX_PI;

	float anglespeed = .9f;
	if (anglespeed > abs(deltaangle))
	{
		SetAngle(destangle);
	}
	else
	{
		float sign = 1.f;
		if (deltaangle < 0.f) sign = -1.f;
		SetAngle(sign * anglespeed + GetAngle());
	}
}
开发者ID:seobyeongky,项目名称:gunscape,代码行数:26,代码来源:player.cpp

示例2: memset

/**\brief Ship constructor that initializes default values.
 */
Ship::Ship()
{
	model = NULL;
	engine = NULL;
	flareAnimation = NULL;
	
	/* Initalize ship's condition */
	damageBooster=1.0;
	engineBooster=1.0;
	shieldBooster=1.0;
	status.hullDamage = 0;
	status.shieldDamage = 0;
	status.lastWeaponChangeAt = 0;

	memset(status.lastFiredAt, 0, sizeof(status.lastFiredAt));

	status.selectedWeapon = 0;
	status.cargoSpaceUsed = 0;
	status.isAccelerating = false;
	status.isRotatingLeft = false;
	status.isRotatingRight = false;
	status.isDisabled = false;
	for(int a=0;a<max_ammo;a++){
		ammo[a]=0;
	}

	shipStats = Outfit();

	SetRadarColor( RED );
	SetAngle( float( rand() %360 ) );
}
开发者ID:markettwp,项目名称:Epiar,代码行数:33,代码来源:ship.cpp

示例3: CreateImageSource

OGSprite* SpriteFactory::CreateCap(WOGPipe* a_pipe,
                                   const QString& a_id,
                                   bool a_visible)
{
    auto src = CreateImageSource(a_id);

    if (!src || a_pipe->vertex->size() < 2)
        return nullptr;

    QPointF p1 = a_pipe->vertex->at(0);
    QPointF p2 = a_pipe->vertex->at(1);
    auto v = p2 - p1;
    float angle = (v.x() == 0 ? (v.y() > 0 ? 0 : 180) : (v.x() > 0 ? 90 : -90));

    float x = p1.x();
    float y = -p1.y();

    auto spr = std::unique_ptr<OGSprite>(new OGSprite(x, y, src));
    spr->CenterOrigin();
    spr->SetAngle(angle);
    spr->SetVisible(a_visible);
    spr->SetDepth(a_pipe->depth);

    return spr.release();
}
开发者ID:Mandarancio,项目名称:OpenGOO,代码行数:25,代码来源:spritefactory.cpp

示例4: InitThingSet

//////////////////////////////////////////////////////////////////////
// TThingEditDialog
// ----------
//
void
TThingEditDialog::SetupWindow ()
{
	TDialog::SetupWindow();
	::CenterWindow (this);

	// Retreive thing set and setup check boxes
	InitThingSet ();

	// Add thing types of thing set in list box
	SetupListBox();

	// Set angle and appearence boxes
	SetAngle();

	// Insert thing position in edit boxes
	char tmp[20];
	sprintf (tmp, "%d", CurThing.xpos);
	pXPosEdit->SetText(tmp);

	sprintf (tmp, "%d", CurThing.ypos);
	pYPosEdit->SetText(tmp);

	sprintf (tmp, "%d", CurThing.xExitPos);
	pXExit->SetText(tmp);

	sprintf (tmp, "%d", CurThing.yExitPos);
	pYExit->SetText(tmp);

	pComment->SetText(CurThing.comment);
}
开发者ID:Tatsujinichi,项目名称:Meridian59,代码行数:35,代码来源:thingdlg.cpp

示例5: SelectEntrance

void TThingEditDialog::SelectFromEntrancesClicked ()
{
  // Disabled 7/3/04 ARK.  See comment in windeu.cpp about entrances
#if 0  
	int startExitRoomID = CurThing.when;
	int exitRoomID,exitRow,exitCol,exitAngle;
	int id = SelectEntrance(this,startExitRoomID,CurThing.id,&exitRoomID,&exitRow,&exitCol,&exitAngle);
	if (id >= 0)
	{
		int roomIndex = GetKodIndexFromID(exitRoomID);
		if (roomIndex >= 0)
		{
			char tmp[256];
			sprintf (tmp, "%d", exitCol);
			pXExit->SetText(tmp);
			sprintf (tmp, "%d", exitRow);
			pYExit->SetText(tmp);
			pExitRoomID->SetSelIndex(pExitRoomID->FindString(GetKodRoomDecorativeName(roomIndex),-1));
			CurThing.xExitPos = exitCol;
			CurThing.yExitPos = exitRow;
			CurThing.id = id;
			CurThing.angle = exitAngle;
			CurThing.when = exitRoomID;
			SetAngle();
			SetupListBox();
		}
	}
#endif
}
开发者ID:Tatsujinichi,项目名称:Meridian59,代码行数:29,代码来源:thingdlg.cpp

示例6: GetAngle

/**\brief Rotates the ship in the given direction (relative angle).
 * \param direction Relative angle to rotate by
 * \sa Model::GetRotationsperSecond()
 */
void Ship::Rotate( float direction ) {
	float rotPerSecond, timerDelta, maxturning;
	float angle = GetAngle();
	
	if( !model ) {
		LogMsg(WARN, "Attempt to rotate sprite with no model." );
		return;
	}

	// Compute the maximum amount that the ship can turn
	rotPerSecond = shipStats.GetRotationsPerSecond();
	timerDelta = Timer::GetDelta();
	maxturning = static_cast<float>((rotPerSecond * timerDelta) * 360.);

	// Cap the ship rotation
	if (fabs(direction) > maxturning){
		if (direction > 0 )
			angle += maxturning;
		else
			angle -= maxturning;
	} else {
		angle += direction;
	}
	
	// Normalize
	angle = normalizeAngle(angle);
	
	SetAngle( angle );
}
开发者ID:eoi,项目名称:Epiar,代码行数:33,代码来源:ship.cpp

示例7: SetAxis

void xTEDSOrientationItem::SetOrientation(const orientation* NewOrientation)
{
	if (NewOrientation == NULL) return;
	SetAxis(NewOrientation->axis_value);
	SetAngle(NewOrientation->angle_value);
	SetUnits(NewOrientation->units_value);
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:7,代码来源:xTEDSOrientationItem.cpp

示例8: sqrt

void Player::DoUpdate(int iCurrentTime)
{
	// Get time since last update
	double delta = iCurrentTime - _previousTime;

	// Get x y components of distance to mouse
	double dx = _pGameMain->GetCurrentMouseX() - _x;
	double dy =  _pGameMain->GetCurrentMouseY() - _y;

	// Euclidean distance to mouse
	double dist = sqrt(pow(dx, 2) + pow(dy, 2));

	// Vary speed based upon distance from mouse
	if (dist > 1 && dist < 50)
		SetSpeed(_maxVelocity * dist / 50);
	else if (dist > 1)
		SetSpeed(_maxVelocity);
	else
		SetSpeed(0);

	// Set angle to point towards the mouse
	int angle = (int) ((atan2(dy, dx) * 180 / PI) + 450) % 360;
	SetAngle(angle);

	CheckPowerups(iCurrentTime);
	CheckKeys(iCurrentTime);

	// Call to the super call DoUpdate method
	Actor::DoUpdate(iCurrentTime);
}
开发者ID:marcuswhybrow,项目名称:g52cfj-cw1-windows,代码行数:30,代码来源:Player.cpp

示例9: Effect

/**\brief Update the Projectile
 *
 * Projectiles do all the normal Sprite things like moving.
 * Projectiles check for collisions with nearby Ships, and if they collide,
 * they deal damage to that ship. Note that since each projectile knows which ship fired it and will never collide with them.
 *
 * Projectiles have a life time limit (in milli-seconds).  Each tick they need
 * to check if they've lived to long and need to disappear.
 *
 * Projectiles have the ability to track down a specific target.  This only
 * means that they will turn slightly to head towards their target.
 */
void Projectile::Update( void ) {
	Sprite::Update(); // update momentum and other generic sprite attributes
	SpriteManager *sprites = SpriteManager::Instance();

	// Check for projectile collisions
	Sprite* impact = sprites->GetNearestSprite( (Sprite*)this, 100,DRAW_ORDER_SHIP|DRAW_ORDER_PLAYER );
	if( (impact != NULL) && (impact->GetID() != ownerID) && ((this->GetWorldPosition() - impact->GetWorldPosition()).GetMagnitude() < impact->GetRadarSize() )) {
		((Ship*)impact)->Damage( (weapon->GetPayload())*damageBoost );
		sprites->Delete( (Sprite*)this );
		
		// Create a fire burst where this projectile hit the ship's shields.
		// TODO: This shows how much we need to improve our collision detection.
		Effect* hit = new Effect(this->GetWorldPosition(), "Resources/Animations/shield.ani", 0);
		hit->SetAngle( -this->GetAngle() );
		hit->SetMomentum( impact->GetMomentum() );
		sprites->Add( hit );
	}

	// Expire the projectile after a time period
	if (( Timer::GetTicks() > secondsOfLife + start )) {
		sprites->Delete( (Sprite*)this );
	}

	// Track the target
	Sprite* target = sprites->GetSpriteByID( targetID );
	float tracking = weapon->GetTracking();
	if( target != NULL && tracking > 0.00000001f ) {
		float angleTowards = normalizeAngle( ( target->GetWorldPosition() - this->GetWorldPosition() ).GetAngle() - GetAngle() );
		SetMomentum( GetMomentum().RotateBy( angleTowards*tracking ) );
		SetAngle( GetMomentum().GetAngle() );
	}
}
开发者ID:eoi,项目名称:Epiar,代码行数:44,代码来源:projectile.cpp

示例10: SetRadarColor

/**\brief Constructor
 */
Projectile::Projectile(float damageBooster, float angleToFire, Coordinate worldPosition, Coordinate firedMomentum, Weapon* _weapon)
{
	damageBoost=damageBooster;
	// All Projectiles get these
	ownerID = 0;
	targetID = 0;
	start = Timer::GetTicks();
	SetRadarColor (Color(0x55,0x55,0x55));

	// These are based off of the Ship firing this projectile
	SetWorldPosition( worldPosition );
	SetAngle(angleToFire);

	// These are based off of the Weapon
	weapon = _weapon;
	secondsOfLife = weapon->GetLifetime();
	SetImage(weapon->GetImage());

	Trig *trig = Trig::Instance();
	Coordinate momentum = GetMomentum();
	float angle = static_cast<float>(trig->DegToRad( angleToFire ));

	momentum = firedMomentum +
	           Coordinate( trig->GetCos( angle ) * weapon->GetVelocity(),
	                      -trig->GetSin( angle ) * weapon->GetVelocity() );
	
	SetMomentum( momentum );
}
开发者ID:eoi,项目名称:Epiar,代码行数:30,代码来源:projectile.cpp

示例11: SetDuration

//-----------------------------------------------------------------------------
void CFireBall::Create(Vec3f aeSrc, float afBeta, float afAlpha, float _fLevel)
{
	SetDuration(ulDuration);
	SetAngle(afBeta);

	eSrc.x = aeSrc.x - fBetaRadSin * 60;
	eSrc.y = aeSrc.y;
	eSrc.z = aeSrc.z + fBetaRadCos * 60;

	eMove.x = - fBetaRadSin * 80 * cos(radians(MAKEANGLE(afAlpha)));
	eMove.y = sin(radians(MAKEANGLE(afAlpha))) * 80;
	eMove.z = + fBetaRadCos * 80 * cos(radians(MAKEANGLE(afAlpha)));

	fLevel = _fLevel;

	//FIRE
	fire_1.p3Direction = -eMove;
	fire_1.fStartSize = 1 * _fLevel; 
	fire_1.fStartSizeRandom = 2 * _fLevel; 

	pPSFire.SetParams(fire_1);
	pPSFire.fParticleFreq = 100.0f;
	pPSFire.ulParticleSpawn = 0;
	pPSFire.SetTexture("graph/particles/fire", 0, 200);

	pPSFire.Update(0);

	//FIRE
	fire_2.p3Direction = -eMove;
	fire_2.fStartSize = 1 * _fLevel; 
	fire_2.fStartSizeRandom = 2 * _fLevel; 
	fire_2.fEndSize = 3 * _fLevel; 
	fire_2.fEndSizeRandom = 2 * _fLevel; 

	pPSFire2.SetParams(fire_2);
	pPSFire2.fParticleFreq = 20.0f;
	pPSFire2.ulParticleSpawn = 0;
	pPSFire2.SetTexture("graph/particles/fire", 0, 200);
	pPSFire2.Update(0);

	// Smoke
	smoke.p3Direction = -eMove;
	smoke.fEndSize = 7 * _fLevel;
	smoke.fEndSizeRandom = 2 * _fLevel; 

	pPSSmoke.SetParams(smoke);
	pPSSmoke.ulParticleSpawn = 0;
	pPSSmoke.fParticleFreq = 20.0f;

	pPSSmoke.SetTexture("graph/particles/big_greypouf", 0, 0);
	pPSSmoke.Update(0);

	pPSFire.SetPos(eSrc);
	pPSFire2.SetPos(eSrc);
	pPSSmoke.SetPos(eSrc);

	// Light
	lLightId = -1; 
	eCurPos = eSrc;
}
开发者ID:Eli2,项目名称:ArxLibertatis,代码行数:61,代码来源:Spells03.cpp

示例12: lstrlen

//------------------------------------------------------
//	コンストラクタ
//------------------------------------------------------
iexMesh::iexMesh( char* filename )
{
	lpMesh = NULL;
	lpTexture = NULL;
	lpNormal = NULL;
	lpSpecular = NULL;
	lpHeight = NULL;

	//	ファイル読み込み
	char*	ext = &filename[ lstrlen(filename)-4 ];
	if( lstrcmpi( ext, ".imo" ) == 0 ) LoadIMO(filename);
	 else LoadX(filename);

	if( lpMesh == NULL )
	{
		//	読み込み失敗
		tdnSystem::printf( "*エラー[iexMesh] ---> ロード失敗: \"%s\"\n", filename );
		bLoad = FALSE;
	} else {
		DWORD* pAdjacency = new DWORD [ lpMesh->GetNumFaces() * 3 ];
		// 最適化
		lpMesh->GenerateAdjacency( 1e-6f, pAdjacency );
		lpMesh->OptimizeInplace( D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE, pAdjacency, NULL, NULL, NULL );
		delete[] pAdjacency;

		bLoad = TRUE;
	}
	SetPos(0,0,0);
	SetScale(1.0f);
	SetAngle(0);
	Update();
}
开发者ID:TDNLibraryProject,项目名称:main,代码行数:35,代码来源:IEX_Mesh.cpp

示例13: SetDuration

//-----------------------------------------------------------------------------
void CMagicMissile::Create(EERIE_3D aeSrc, EERIE_3D angles)
{
	int i;
	EERIE_3D s, e;

	SetDuration(ulDuration);
	SetAngle(angles.b);

	Vector_Copy(&this->angles, &angles);
	eCurPos.x = eSrc.x = aeSrc.x;
	eCurPos.y = eSrc.y = aeSrc.y;
	eCurPos.z = eSrc.z = aeSrc.z;


	fSize = 1;
	bDone = true;

	s.x = eSrc.x;
	s.y = eSrc.y;
	s.z = eSrc.z;
	e.x = eSrc.x;
	e.y = eSrc.y;
	e.z = eSrc.z;

	i = 0;

	i = 40;
	e.x -= fBetaRadSin * 50 * i;
	e.y += sin(DEG2RAD(MAKEANGLE(this->angles.a))) * 50 * i;
	e.z += fBetaRadCos * 50 * i;

	pathways[0].sx = eSrc.x;
	pathways[0].sy = eSrc.y;
	pathways[0].sz = eSrc.z;
	pathways[5].sx = e.x;
	pathways[5].sy = e.y;
	pathways[5].sz = e.z;
	Split(pathways, 0, 5, 50, 0.5f);

	for (i = 0; i < 6; i++)
	{
		if (pathways[i].sy >= eSrc.y + 150)
		{
			pathways[i].sy = eSrc.y + 150;
		}
	}

	fTrail = 0;

	iLength = 50;
	fOneOnLength = 1.0f / (float) iLength;
	iBezierPrecision = BEZIERPrecision;
	fOneOnBezierPrecision = 1.0f / (float) iBezierPrecision;
	bExplo = false;
	bMove = true;

	ARX_SOUND_PlaySFX(SND_SPELL_MM_CREATE, &eCurPos);
	ARX_SOUND_PlaySFX(SND_SPELL_MM_LAUNCH, &eCurPos);
	snd_loop = ARX_SOUND_PlaySFX(SND_SPELL_MM_LOOP, &eCurPos, 1.0F, ARX_SOUND_PLAY_LOOPED);
}
开发者ID:sopyer,项目名称:ArxFatalis,代码行数:61,代码来源:ARX_SpellFX_Lvl01.cpp

示例14: TextObject2D_Rotate

/**
@brief	文字列を回転させて表示するサンプル。
*/
void TextObject2D_Rotate()
{
	// Altseedを初期化する。
	asd::Engine::Initialize(asd::ToAString("TextObject2D_Rotate").c_str(), 640, 480, asd::EngineOption());

	{
		// フォントと文字列描画オブジェクトの設定を行う。
		auto edgeFont = asd::Engine::GetGraphics()->CreateFont(asd::ToAString("Data/Font/Font1.aff").c_str());
		auto edgeObj = std::make_shared<asd::TextObject2D>();
		edgeObj->SetFont(edgeFont);
		edgeObj->SetPosition(asd::Vector2DF(100, 100));

		//回転角と描画する文字列を設定する。
		edgeObj->SetAngle(30);
		edgeObj->SetText(asd::ToAString("文字列の回転描画").c_str());

		// 文字描画オブジェクトのインスタンスをエンジンへ追加する。
		asd::Engine::AddObject2D(edgeObj);
	}

	// Altseedのウインドウが閉じられていないか確認する。
	while (asd::Engine::DoEvents())
	{
		// Altseedを更新する。
		asd::Engine::Update();
	}

	// Altseedを終了する。
	asd::Engine::Terminate();
}
开发者ID:Pctg-x8,项目名称:Altseed,代码行数:33,代码来源:TextObject2D_Rotate.cpp

示例15: SetCenter

void TBox::SetBox(TGfxVec2 Position, float W_Ray, float H_Ray, float Angle)
{
	SetCenter(Position);
	SetRayS(W_Ray, H_Ray);
	SetAngle(Angle);
	SetCollider();
}
开发者ID:OperationKiwiPower,项目名称:Styven_Creation,代码行数:7,代码来源:SC_Box.cpp


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