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


C++ Platform::getType方法代码示例

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


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

示例1: move

void Player::move(const std::vector<Solid*>& solids)
{

	gapToReference = coord.x - (REF_X*800 + (scene->getCam().x-400));

	float rad = motion_angle*PI_ENGINE/180;
	float dx = 0;
	float dy = 0;

	// déplacement normal
	if(motion_angle >= -MAX_MOVE_ANGLE)
	{
		if(motion_angle <= MAX_MOVE_ANGLE)
		{
			dx = SPEED * (1-sin(rad)*std::abs(sin(rad))) * (1-tanh(gapToReference/50)/1.5);
			dy = GRAVITY * timer - 20;
		}
		if(motion_angle <= 90)
		{
			if(!jumping && jumpCommand)	
			{
				if(timer > 20)
					double_jumping = true;
				jumping = true;
				timer = 1;
			}
		}
	}

	// chute libre
	else if(motion_angle < MAX_MOVE_ANGLE && motion_angle >= MAX_MOVE_ANGLE-180)
	{
		dx = SPEED * cos(rad);
		dy = GRAVITY * timer;
	}

	// mode saut
	if(jumping)
	{
		dx = SPEED * (1-sin(rad)*std::abs(sin(rad))) * (1-tanh(gapToReference/50)/5);
		dy = GRAVITY * timer - 26;
		if(dy >= -DBLE_JUMP_SENSIBILITY && dy <= DBLE_JUMP_SENSIBILITY && !double_jumping && timer >= 1.20)
		{
			if(jumpCommand)
			{
				double_jumping = true;	
				timer = 1;
			}
		}
		if(motion_angle == 90 && double_jumping) dx = SPEED;
	}

	float x1 = coord.x;
	float y1 = coord.y;

	float x2 = x1 + dx;
	float y2 = y1 + dy;

	float d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
	int sub_pts = (int)round(d) - 1;

	std::vector<sf::Vector2f> sub_positions;
	sub_positions.push_back(sf::Vector2f(0, 0));
	for(int p = 1; p <= sub_pts; p++)
		sub_positions.push_back(sf::Vector2f(p*(x2-x1)/(sub_pts+1), p*(y2-y1)/(sub_pts+1)));
	sub_positions.push_back(sf::Vector2f(x2-x1, y2-y1));

	bool collisionDetected = false;

	for(int cur_pos = 1; cur_pos < sub_positions.size() && !collisionDetected; cur_pos++)
	{
		for(int i = 0; i < solids.size() && !collisionDetected; i++)
		{
			for(int j = 0; j < hitBox.getSegments().size() && !collisionDetected; j++)
			{
				Segment new_segm(
					hitBox.getSegments()[j].getP1() + sub_positions[cur_pos],
					hitBox.getSegments()[j].getP2() + sub_positions[cur_pos]
				);
				if((solids[i]->getHitBox()).intersectsWith(new_segm))
				{

          if(solids[i]->getEType() == Entity::PLATFORM){
              Platform* plat = (Platform*)(solids[i]);
                if(plat->getType()==Platform::DEADLY)
              dead=true;
          }


		                    	collisionDetected = true;
					jumping = false;
					double_jumping = false;
					timer = 1;
					move(sub_positions[cur_pos-1]);

					int angle = -90;
					float angle_rad;
					int pas = 1;
					bool possible = false;
					sf::Vector2f vect;
//.........这里部分代码省略.........
开发者ID:AS-2013-2014,项目名称:Projet,代码行数:101,代码来源:Player.cpp


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