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


C++ Entity::GetAngle方法代码示例

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


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

示例1: Capture

void Capturable::Capture(void)
{
	const CapturableTemplate &capturable = Database::capturabletemplate.Get(mId);

	// if spawning on capture...
	if (capturable.mSpawnOnCapture)
	{
		// get the entity
		Entity *entity = Database::entity.Get(mId);
		if (entity)
		{
			// instantiate the template
			Database::Instantiate(capturable.mSpawnOnCapture, Database::owner.Get(mId), mId, entity->GetAngle(), entity->GetPosition(), entity->GetVelocity(), entity->GetOmega());
		}
	}

	// if switching on capture...
	if (capturable.mSwitchOnCapture)
	{
		// change dynamic type
		Database::Switch(mId, capturable.mSwitchOnCapture);
	}
	else
	{
		// delete the entity
		Database::Delete(mId);
	}
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:28,代码来源:Capturable.cpp

示例2: Kill

void Pickup::Kill(float aFraction)
{
	const PickupTemplate &pickup = Database::pickuptemplate.Get(mId);

	// if spawning on pickup...
	if (pickup.mSpawnOnCollect)
	{
		// get the entity
		Entity *entity = Database::entity.Get(mId);
		if (entity)
		{
			// spawn template at entity location
			unsigned int spawnId = Database::Instantiate(pickup.mSpawnOnCollect, Database::owner.Get(mId), mId,
				entity->GetAngle(), entity->GetPosition(), entity->GetVelocity(), entity->GetOmega());
			if (Renderable *renderable = Database::renderable.Get(spawnId))
				renderable->SetFraction(aFraction);
		}
	}

	// if switching on pickup...
	if (pickup.mSwitchOnCollect)
	{
		// change dynamic type
		unsigned int aId = mId;
		Database::Switch(aId, pickup.mSwitchOnCollect);
		if (Renderable *renderable = Database::renderable.Get(aId))
			renderable->SetFraction(aFraction);
	}
	else
	{
		// delete the entity
		Database::Delete(mId);
	}

	return;
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:36,代码来源:Pickup.cpp

示例3: Update


//.........这里部分代码省略.........
#ifdef GUNNER_TRACK_DEQUE
	const Vector2 &posL0 = mTrackPos.back();
#else
	const Vector2 &posL0 = mTrackPos[mTrackLast];
#endif
	float movement = posP.DistSq(posL0);

	// if the owner has moved...
	if (movement > FLT_EPSILON)
	{
#ifdef GUNNER_TRACK_DEQUE
		// get the last segment
		const Vector2 &posL1 = mTrackPos[mTrackPos.size()-2];
		float lastsegment = posL0.Dist(posL1);

		// if the last segment isn't long enough...
		if (lastsegment < GUNNER_TRACK_GRANULARITY)
		{
			// replace the last segment
			mTrackPos.pop_back();
			mTrackLength -= lastsegment;
		}

		// add new position
		mTrackPos.push_back(posP);
		mTrackLength += posP.Dist(mTrackPos[mTrackPos.size()-2]);
#else
		// get the last segment
		size_t mTrackPrev = (mTrackLast > 0) ? (mTrackLast - 1) : (mTrackCount - 1);
		const Vector2 &posL1 = mTrackPos[mTrackPrev];
		float lastsegment = posL0.Dist(posL1);

		// if the last segment is long enough...
		if (lastsegment >= GUNNER_TRACK_GRANULARITY)
		{
			// start a new segment
			mTrackPrev = mTrackLast;
			mTrackLast = (mTrackLast < mTrackCount - 1) ? (mTrackLast + 1) : 0;
		}
		else
		{
			// replace the last segment
			mTrackLength -= lastsegment;
		}

		// add new position
		mTrackPos[mTrackLast] = posP;
		mTrackLength += posP.Dist(mTrackPos[mTrackPrev]);
#endif

		// while there is excess track length...
		while (mTrackLength > gunner.mFollowLength)
		{
			// get the excess length
			float excess = mTrackLength - gunner.mFollowLength;

			// get the first segment length
#ifdef GUNNER_TRACK_DEQUE
			Vector2 &pos0 = mTrackPos[0];
			const Vector2 &pos1 = mTrackPos[1];
#else
			size_t mTrackNext = (mTrackFirst < mTrackCount - 1) ? (mTrackFirst + 1) : 0;
			Vector2 &pos0 = mTrackPos[mTrackFirst];
			const Vector2 &pos1 = mTrackPos[mTrackNext];
#endif
			float firstsegment = pos0.Dist(pos1);

			// if the segment is longer than the excess...
			if (firstsegment > excess)
			{
				// shorten the segment
				pos0 += excess / firstsegment * (pos1 - pos0);
				mTrackLength -= excess;
				break;
			}
			else
			{
				// remove the segment
				mTrackLength -= firstsegment;
#ifdef GUNNER_TRACK_DEQUE
				mTrackPos.pop_front();
#else
				mTrackFirst = mTrackNext;
#endif
			}
		}
	}

	// move to new position
	Entity *entity = Database::entity.Get(mId);
	entity->Step();
#ifdef GUNNER_TRACK_DEQUE
	entity->SetPosition(mTrackPos.front());
#else
	entity->SetPosition(mTrackPos[mTrackFirst]);
#endif
	entity->SetAngle(owner->GetAngle());
	entity->SetVelocity(owner->GetVelocity());	// <-- HACK!
	entity->SetOmega(owner->GetOmega());
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:101,代码来源:Gunner.cpp

示例4: Cancel

// cancel
void Cancelable::Cancel(unsigned int aId, unsigned int aSourceId)
{
	const CancelableTemplate &cancelable = Database::cancelabletemplate.Get(mId);

	// set owner to source damage owner
	unsigned int aOwnerId = Database::owner.Get(aSourceId);
	Database::owner.Put(mId, aOwnerId);

	// bump the hit combo counter
	int &combo = Database::hitcombo.Open(mId);
	combo = std::max<int>(combo, Database::hitcombo.Get(aSourceId) + 1);
	Database::hitcombo.Close(mId);

	if (cancelable.mBacklash)
	{
		for (unsigned int creator = Database::creator.Get(aId); creator != 0; creator = Database::backlink.Get(creator))
		{
			if (Damagable *damagable = Database::damagable.Get(creator))
			{
				Damagable::DeathSignal &signal = Database::deathsignal.Open(creator);
				signal.Disconnect(this, &Cancelable::CreatorDeath);
				Database::deathsignal.Close(creator);

//				damagable->Damage(mId, cancelable.mBacklash);

				// burn tether from the cancelable to the creator
				new TetherBurn(creator, mId, aOwnerId, cancelable.mBacklash, combo);
				break;
			}
		}
	}

	// if spawning on cancelable...
	if (cancelable.mSpawn)
	{
		// get the entity
		Entity *entity = Database::entity.Get(mId);
		if (entity)
		{
			// spawn template at the entity location
			Database::Instantiate(cancelable.mSpawn, Database::owner.Get(mId), mId, entity->GetAngle(), entity->GetPosition(), entity->GetVelocity(), entity->GetOmega());
		}
	}

	// if switching on cancelable...
	if (cancelable.mSwitch)
	{
		// get the entity
		Entity *entity = Database::entity.Get(mId);
		if (entity)
		{
			// change dynamic type
			Database::Switch(mId, cancelable.mSwitch);
		}
	}
	else
	{
		// delete the entity
		Database::Delete(mId);
	}
}
开发者ID:Fissuras,项目名称:videoventure,代码行数:62,代码来源:Cancelable.cpp

示例5: main


//.........这里部分代码省略.........
    	sf::Event event;
        Entity* ship = game.GetWorld().GetEntities()[0];

		while (window.pollEvent(event)) {
        //window.PollEvent(event);
			if (event.type == sf::Event::Closed)
				window.close();

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
				return 0;

			if ((event.type == sf::Event::MouseWheelMoved)) {
				options.renderscale += event.mouseWheel.delta*.1f;
			}

			if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space)) {
                Shape* bombShape = Shape::CreateBombShape();
				Entity* bomb = new Entity(game.GetWorld(), *bombShape, ship->GetPos() + Vec2f(1, 1));
                bomb->SetVel(ship->GetVel());
                bomb->SetMass(0.01f);
                game.GetWorld().AddEntity(*bomb);
                
			}
            
            switch(event.type)
            {
                case sf::Event::Resized:
                    //rendererInterface.Resize();
                    break;
                case sf::Event::MouseMoved:
                    Context->ProcessMouseMove(event.mouseMove.x, event.mouseMove.y,
                                              systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseButtonPressed:
                    Context->ProcessMouseButtonDown(event.mouseButton.button,
                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseButtonReleased:
                    Context->ProcessMouseButtonUp(event.mouseButton.button,
                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::MouseWheelMoved:
                    Context->ProcessMouseWheel(event.mouseWheel.delta,
                                               systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::TextEntered:
                    if (event.text.unicode > 32)
                        Context->ProcessTextInput(event.text.unicode);
                    break;
                case sf::Event::KeyPressed:
                    Context->ProcessKeyDown(systemInterface.TranslateKey(event.key.code),
                                            systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::KeyReleased:
                    if(event.key.code == sf::Keyboard::F8)
                    {
                        Rocket::Debugger::SetVisible(!Rocket::Debugger::IsVisible());
                    };

                    Context->ProcessKeyUp(systemInterface.TranslateKey(event.key.code),
                                          systemInterface.GetKeyModifiers(&window));
                    break;
                case sf::Event::Closed:
                    return 1;
                    break;
            };
		}       
        
        int rotate = sf::Keyboard::isKeyPressed(sf::Keyboard::Right) - sf::Keyboard::isKeyPressed(sf::Keyboard::Left);
		bool forward = sf::Keyboard::isKeyPressed(sf::Keyboard::Up);



		sf::View nView(Vec2f(options.hres, options.vres), Vec2f(options.hres, options.vres));
		camera.Update(ship->GetPos() * options.renderscale);
		nView.move(camera.GetPos() - Vec2f(options.hres, options.vres));

        ship->Rotate(rotate*2);
		if (forward)
			ship->ApplyForce(Vec2f(0.f, 2.f).Rotate(ship->GetAngle()));

        window.clear();
        window.setView(nView);
        DrawWorld(window, game.GetWorld(), 0.f);

        sf::View viewEmpty = window.getDefaultView();
        window.setView(viewEmpty);
        Context->Update();
        Context->Render();
        window.setFramerateLimit(60);
        window.display();

        
        game.Step();

    }

    game.Stop();
    return 0;
}
开发者ID:MarcinKoziuk,项目名称:gravity,代码行数:101,代码来源:cmain.cpp


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