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


C++ Portal::setPosition方法代码示例

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


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

示例1: update

void Hero::update()
{
	if (mySpawnPortal)
	{
		mySpawnPortalFrameCounter++;
		if (mySpawnPortalFrameCounter == 1)
		{
			Portal* portal = new Portal();
			portal->setPosition(getPosition());
			getRoom()->addEntity(portal);
			return;
		}
		else if (mySpawnPortalFrameCounter >= 60 * 5)
		{
			mySpawnPortal = false;
		}
		else 
		{
			return;
		}
	}

	if (myIsDead)
		return;

	Entity::update();
	mFramesSinceLandPlayed++;

	if (mGravityHitTimer <= 0){
		mGravityDirection=1;
	} else {
		mGravityHitTimer--;
	}

	if (touchesDangerousTile())
	{
		die();
	}
	//checkEnemies();

	if (mSpawnPoint.x < -100 && mSpawnPoint.y < -100)
	{
		mSpawnPoint = getPosition();
	}

	float acceleration = mOnGround ? GROUND_ACCELERATION : AIR_ACCELERATION;
	
	if (Input::isHeld(Button_Left)) {
		mVelocity.x -= acceleration;
		mFacingDirection = Direction_Left;
	}

	if (Input::isHeld(Button_Right)) {
		mVelocity.x += acceleration;
		mFacingDirection = Direction_Right;
	}

	if(Input::isPressed(Button_Fire) && GameState::getInt(GameState::POWERUP_GRENADE) != 0){
		mWeaponSelected = Weapon_Gravity_Grenade;
		fireWeapon();
	}

	if(Input::isPressed(Button_ToggleWeapon) && GameState::getInt(GameState::POWERUP_GUN) != 0){
		mWeaponSelected = Weapon_Gun;
		fireWeapon();
	}

	mVelocity.x = clamp(mVelocity.x, -MAX_X_VELOCITY, MAX_X_VELOCITY);
	
	if (Input::isPressed(Button_Jump)) {
		mJumpPrepressed = true;
	}

	if (mOnGround && mJumpPrepressed) {
		Sound::playSample("data/sounds/jump.wav");
		mVelocity.y = GameState::getInt(GameState::POWERUP_HIJUMP) ? -HI_JUMP_VELOCITY : -JUMP_VELOCITY;
		mJumpHeld = true;
		mJumpPrepressed = false;
	}

	if (Input::isReleased(Button_Jump)) {
		if (mJumpHeld && mVelocity.y < 0) {
			mVelocity.y *= 0.5f;
		}

		mJumpHeld = false;
		mJumpPrepressed = false;
	}

	if (mVelocity.y >= 0) {
		mJumpHeld = false;
	}

	mMovementState = MovementState_Still;
	
	if (mOnGround) {
		if (abs(mVelocity.x) > GROUND_STOP_VELOCITY)
		{
			mMovementState = MovementState_Run;
		}
//.........这里部分代码省略.........
开发者ID:GassaFM,项目名称:TINS-is-not-speedhack-2012,代码行数:101,代码来源:Hero.cpp


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