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


C++ Physics::moveobject方法代码示例

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


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

示例1: update

	int8_t Player::update(const Physics& physics, uint16_t dpf)
	{
		const PlayerState* pst = plstates.get(stance);
		if (pst)
		{
			pst->update(*this);
			physics.moveobject(phobj, dpf);
			pst->nextstate(*this);
		}

		uint16_t lookdpf = dpf;
		switch (stance)
		{
		case PST_WALK:
			lookdpf = static_cast<short>(dpf * (1.0f + abs(phobj.hspeed) / 25));
			break;
		}
		look.update(lookdpf);

		return phobj.fhlayer;
	}
开发者ID:pandaforks,项目名称:JourneyClient,代码行数:21,代码来源:Player.cpp

示例2: update

	int8_t Drop::update(const Physics& physics)
	{
		physics.moveobject(phobj);

		if (state == DROPPED && phobj.onground)
		{
			phobj.hspeed = 0.0;
			phobj.setflag(PhysicsObject::NOGRAVITY);
			setposition(dest.x(), dest.y() - 4);
			state = FLOATING;
		}
		
		if (state == FLOATING)
		{
			phobj.y = basey + 5.0f + (cos(moved) - 1.0f) * 2.5f;
			moved = (moved < 360.0f) ? moved + 0.025f : 0.0f;
		}
		
		if (state == PICKEDUP)
		{
			static const uint16_t PICKUPTIME = 48;

			if (looter)
			{
				double hdelta = looter->x - phobj.x;
				phobj.hspeed = looter->hspeed / 2.0 + (hdelta - 16.0) / PICKUPTIME;
			}

			opacity -= 1.0f / PICKUPTIME;
			if (opacity <= 1.0f / PICKUPTIME)
			{
				opacity = 0.0f;

				MapObject::deactivate();
				return -1;
			}
		}

		return phobj.fhlayer;
	}
开发者ID:eaxvac,项目名称:JourneyClient,代码行数:40,代码来源:Drop.cpp

示例3: update

	int8_t MapObject::update(const Physics& physics)
	{
		physics.moveobject(phobj);
		return phobj.fhlayer;
	}
开发者ID:aadarshasubedi,项目名称:JourneyClient,代码行数:5,代码来源:MapObject.cpp

示例4: update

	int8_t Mob::update(const Physics& physics)
	{
		if (!active)
			return phobj.fhlayer;

		bool aniend = animations.at(stance).update();
		if (aniend && stance == DIE)
		{
			dead = true;
		}

		if (fading)
		{
			opacity -= 0.025f;
			if (opacity.last() < 0.025f)
			{
				opacity.set(0.0f);
				fading = false;
				dead = true;
			}
		}
		else if (fadein)
		{
			opacity += 0.025f;
			if (opacity.last() > 0.975f)
			{
				opacity.set(1.0f);
				fadein = false;
			}
		}

		if (dead)
		{
			active = false;
			return -1;
		}

		effects.update();
		showhp.update();

		if (!dying)
		{
			if (!canfly)
			{
				if (phobj.flagnotset(PhysicsObject::TURNATEDGES))
				{
					flip = !flip;
					phobj.setflag(PhysicsObject::TURNATEDGES);

					if (stance == HIT)
						setstance(STAND);
				}
			}

			switch (stance)
			{
			case MOVE:
				if (canfly)
				{
					phobj.hforce = flip ? flyspeed : -flyspeed;
					switch (flydirection)
					{
					case UPWARDS:
						phobj.vforce = -flyspeed;
						break;
					case DOWNWARDS:
						phobj.vforce = flyspeed;
						break;
					}
				}
				else
				{
					phobj.hforce = flip ? speed : -speed;
				}
				break;
			case HIT:
				if (canmove)
				{
					double KBFORCE = phobj.onground ? 0.2 : 0.1;
					phobj.hforce = flip ? -KBFORCE : KBFORCE;
				}
				break;
			case JUMP:
				phobj.vforce = -5.0;
				break;
			}

			physics.moveobject(phobj);

			if (control)
			{
				counter++;

				bool next;
				switch (stance)
				{
				case HIT:
					next = counter > 200;
					break;
				case JUMP:
//.........这里部分代码省略.........
开发者ID:snopboy,项目名称:JourneyClient,代码行数:101,代码来源:Mob.cpp

示例5: update


//.........这里部分代码省略.........
			if (single.delay <= Constants::TIMESTEP)
			{
				applysingle(single);
				return true;
			}
			else
			{
				single.delay -= Constants::TIMESTEP;
				return false;
			}
		});
		bool nosingle = singlelist.size() == 0;

		size_t remove = 0;
		for (auto& dmg : damagenumbers)
		{
			if (dmg.update())
				remove++;
		}
		for (size_t i = remove; i--;)
		{
			damagenumbers.erase(damagenumbers.begin());
		}
		bool nonumbers = damagenumbers.size() == 0;

		if (dead && nobullets && nosingle && nonumbers)
		{
			active = false;
			return -1;
		}

		effects.update();
		showhp.update();

		if (control && !dying)
		{
			if (!canfly)
			{
				if (phobj.flagnotset(PhysicsObject::TURNATEDGES))
				{
					flip = !flip;
					phobj.setflag(PhysicsObject::TURNATEDGES);

					if (stance == HIT)
						setstance(STAND);
				}
			}

			switch (stance)
			{
			case MOVE:
				if (canfly)
				{
					phobj.hforce = flip ? flyspeed : -flyspeed;
					switch (flydirection)
					{
					case UPWARDS:
						phobj.vforce = -flyspeed;
						break;
					case DOWNWARDS:
						phobj.vforce = flyspeed;
						break;
					}
				}
				else
				{
					phobj.hforce = flip ? speed : -speed;
					if (canjump && phobj.onground && counter > 50 && counter < 150 && randomizer.below(0.005f))
					{
						phobj.vforce = -5.0f;
					}
				}
				break;
			case HIT:
				if (canmove)
				{
					double KBFORCE = phobj.onground ? 0.2 : 0.1;
					phobj.hforce = flip ? -KBFORCE : KBFORCE;
				}
				break;
			}

			counter++;
			if (aniend && counter > 200)
			{
				nextmove();
				sendmovement();
				counter = 0;
			}

			physics.moveobject(phobj);
		}
		else
		{
			phobj.normalize();
			physics.getfht().updatefh(phobj);
		}

		return phobj.fhlayer;
	}
开发者ID:eaxvac,项目名称:JourneyClient,代码行数:101,代码来源:Mob.cpp


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