Ejemplo n.º 1
0
const JPSPlusPathFinder::Cell* JPSPlusPathFinder::Jump(const Cell* nextCell, const Cell* goalCell, Direction direction, bool& outIsCompleted, Direction& outMarkedDirection)
{
	/* assert(next_cell != nullptr); */
	const Cell *nextNextCell1, *nextNextCell2, *nextNextCell3;

	if (nextCell == goalCell)
	{
		outIsCompleted = true;
		outMarkedDirection = direction;
		return nextCell;
	}

	if (!IsDirectionDiagonal(direction))
	{
		if (((!NextWalkableCell(nextCell, (direction)+3) && NextWalkableCell(nextCell, (direction)+2)) || (!NextWalkableCell(nextCell, (direction)+5) && NextWalkableCell(nextCell, (direction)+6))))
			return nextCell;
	}
	else
	{
		nextNextCell1 = NextWalkableCell(nextCell, direction + 1);
		if (nextNextCell1 && Jump(nextNextCell1, goalCell, direction + 1, outIsCompleted, outMarkedDirection))
			return nextCell;

		nextNextCell2 = NextWalkableCell(nextCell, direction - 1);
		if (nextNextCell2 && Jump(nextNextCell2, goalCell, direction - 1, outIsCompleted, outMarkedDirection))
			return nextCell;
		/* can't walk through DIAGONAL block */
		if (!nextNextCell1 || !nextNextCell2)
			return nullptr;
	}

	nextNextCell3 = NextWalkableCell(nextCell, direction);
	return nextNextCell3 ? Jump(nextNextCell3, goalCell, direction, outIsCompleted, outMarkedDirection) : nullptr;
}
Ejemplo n.º 2
0
void Animal::Move(World &world)
{
	if (m_isAlive)
	{
		m_vitesse.x = 0.05;
		m_vitesse.z = 0.05;

		if (m_ClockTarget.getElapsedTime().asSeconds() < m_timeNextTarget)
		{
			Vector3<float> deplacementVector = Vector3<float>(sin(m_HorizontalRot / 180 * PI), 0.f, cos(m_HorizontalRot / 180 * PI));
			deplacementVector.Normalize();

			//Avance en x
			m_pos.x += deplacementVector.x * m_vitesse.x;
			if (CheckCollision(world))
			{
				m_pos.x -= deplacementVector.x * m_vitesse.x;
				Jump();
			}
			//En z
			m_pos.z += deplacementVector.z * m_vitesse.z;
			if (CheckCollision(world))
			{
				m_pos.z -= deplacementVector.z * m_vitesse.z;
				Jump();
			}
		}
		else
		{
			m_HorizontalRot += rand() % 200 - 100;
			m_timeNextTarget = rand() % 10;
			m_ClockTarget.restart();
		}



		//Chute
		m_pos.y -= m_vitesse.y;

		//Si collision
		if (CheckCollision(world))
		{

			//Si on a touche le sol 
			if (m_vitesse.y > 0)
				m_isInAir = false;

			//annule
			m_pos.y += m_vitesse.y;
			m_vitesse.y = 0;
		}
		else
			m_isInAir = true;

		//Acceleration
		m_vitesse.y += 0.013f;

	}
}
Ejemplo n.º 3
0
    inline int Stupid(int x,int y){
        if(d[x]>d[y])swap(x,y);
        int px=x,py=y,ans=0;
#define Jump(x) ans+=!v[COT2::a[x]],v[COT2::a[x]]=1,x=f[x]
        while(d[x]!=d[y])Jump(y);
        while(x!=y)Jump(x),Jump(y);
        ans+=!v[COT2::a[x]];
        while(px!=x)v[COT2::a[px]]=0,px=f[px];
        while(py!=y)v[COT2::a[py]]=0,py=f[py];
        return ans;
    }
Ejemplo n.º 4
0
void Entity::GoUpDown(float dt)
{
	if (mGoUp)
	{
		Jump(dt*movementMult);
		if (mPosition.y > mOrigY + mHeightToGo){ mGoUp = false; mGoDown = true; }
	}
	if (mGoDown)
	{
		Jump(-dt*movementMult);
		if (mPosition.y < mOrigY - mHeightToGo){ mGoUp = true; mGoDown = false; }
	}
}
Ejemplo n.º 5
0
void Fall_Block::NotStoped()
{
	Gravity();
	Move();
	Jump();
	Stop();
}
Ejemplo n.º 6
0
// LexicalAnalyzer获取器,得到常数对应的Token
bool LexicalAnalyzer::GetConstantNumber(Token *result) {
  istr numberBuilder = "";
  bool successFlag = false;
  char c;
  // 扫描数字序列
  while (PTRnextLetter < (int)this->GetSourceCode().length()) {
    c = this->GetSourceCode()[PTRnextLetter];
    if ('0' <= c && c <= '9') {
      // 压数字
      numberBuilder += c;
      // 跳动游程
      Jump(1);
      successFlag = true;
    }
    else {
      break;
    }
  }
  // 成功得到了数字token
  if (successFlag) {
    result->aType = TokenType::number;
    result->detail = numberBuilder;
    result->aTag = atoi(numberBuilder.c_str());
    return true;
  }
  return false;
}
Ejemplo n.º 7
0
void Player::Update(float deltaTime){
	animationTime+=deltaTime;
	isBlocking = false;
	if(KeyHandler::getKeys()->Key_Space)
	{
		Body->SetTransform(Body->GetPosition(),1.57079633f);
		isBlocking=true;
		jumpCharge=0;
	}
	else
	{
		Body->SetTransform(Body->GetPosition(),0);
		isBlocking=false;
		if(KeyHandler::getKeys()->Key_Up)
		{
			jumpCharge-=(jumpForceLevel+jumpCharge)/50;
		}
		else if(jumpCharge!=0)
		{
			Jump();
			jumpCharge=0;
			inAir = true;
		}
		if(KeyHandler::getKeys()->Key_Left)
			this->MoveLeft();
		if(KeyHandler::getKeys()->Key_Right)
			MoveRight();
	}


}
Ejemplo n.º 8
0
//=============================================================================
void CInsect::OnLoop(){
	CEntity::OnLoop();//entity version

	if(faceRight && SpeedY != 0) {//if its facing to the right and its moving in the y direction
		MoveRight = true;//make it move to the right
		MoveLeft = false;
	}
	else if (faceLeft && SpeedY != 0){//if its facing to the left and its moving in the y dirction
		MoveLeft = true;//make it move to the left
		MoveRight = false;
	}
	
	if (SpeedY == 0) {//if its not moving in the y direction
		MoveLeft = false;//make it stop moving in the x direction
		MoveRight = false;
	}	
	
	if(CanJump && jumpTimer >= 100) {//if it can jump and its jump timer is greater then 100 cycles
		jumpTimer = 0;//reset its jump timer
		Jump();//make it jump
	}	

	if(collisionTimer <= 100) collisionTimer++;//if its collision timer is less then 100 increment it
	
}
Ejemplo n.º 9
0
// main function
extern void main(void) {
    temp = 0;
    char buffer[9];
    // setup SYS interrupt
    aic_configure_irq(AT91C_ID_SYS, AT91C_AIC_PRIOR_LOWEST,
                      AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, aic_asm_sys_handler);
    // enable SYS interrupt
    aic_enable_irq(AT91C_ID_SYS);
    // setup rtt - 1Hz clock
    AT91C_BASE_ST->ST_RTMR = 0x4000;
    // setup rtt interrupt flag
    AT91C_BASE_ST->ST_IER = AT91C_ST_RTTINC;
    // enable RXRDY interrupt in DBGU
    AT91C_BASE_DBGU->DBGU_IER |= AT91C_US_RXRDY;
    while(!temp);
    delay(100000);
    util_int_to_hex(temp, buffer);
    if (temp > 0) {
        put_string("\n\nTransfer complete\n");
        put_string("Byte's sended: ");
        put_string(buffer);
        put_string("\n");
        put_string("Jump to loaded code\n");
        Jump((unsigned int)0x20000000);
    } else {
        put_string("Transfer failed\n");
    }
    // Infinity loop
    while (1) {
        // Disable pck for idle cpu mode
        AT91C_BASE_PMC->PMC_SCDR = AT91C_PMC_PCK;
    }
}
void ATopDown_HitmanCleanCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location){
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
Ejemplo n.º 11
0
void BakaEngine::BakaJump(QStringList &args)
{
    if(args.empty())
        Jump();
    else
        InvalidParameter(args.join(' '));
}
Ejemplo n.º 12
0
static void ContinueStmt( void )
{
    BLOCKPTR    block;
    int         try_scope;

    NextToken();
    if( LoopStack != NULL ) {
        if( ! DeadCode ) {                              /* 05-apr-92 */
            try_scope = -2;
            block = BlockStack;
            while( block != LoopStack ) {
                if( ( block->block_type == T__TRY )
                        || ( block->block_type == T___TRY ) ) {
                    try_scope = block->parent_index;
                }
                block = block->prev_block;
            }
            if( try_scope != -2 ) {
                UnWindTry( try_scope );
            }
            if( LoopStack->continue_label == 0 ) {
                LoopStack->continue_label = NextLabel();
            }
            Jump( LoopStack->continue_label );
        }
    } else {
        CErr1( ERR_MISPLACED_CONTINUE );
    }
    MustRecog( T_SEMI_COLON );
}
Ejemplo n.º 13
0
void Camera3::Update(double dt, bool* myKeys)
{/*
	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	Inertia: instant dir change

	* strafe */
	if(myKeys[KEY_A] && !myKeys[KEY_D])
		Strafe(-dt);
	else if(straftMovingLeft)
		DecelerateLeft(-dt);

	if(myKeys[KEY_D] && !myKeys[KEY_A])
		Strafe(dt);
	else if(straftMovingRight)
		DecelerateRight(dt);

	/* walk */
	if(myKeys[KEY_W] && !myKeys[KEY_S])
		Walk(dt);
	else if(walkMovingForward)
		DecelerateForward(dt);

	if(myKeys[KEY_S] && !myKeys[KEY_W])
		Walk(-dt);
	else if(walkMovingBackward)
		DecelerateBackward(-dt);

	if(myKeys[KEY_C] && !croutching)
		croutching = true;

	croutch(dt);


	/* fly */
	if(myKeys[KEY_K])
		Fly(dt);
	if(myKeys[KEY_L])
		Fly(-dt);

	if(myKeys[KEY_SPACE] && !jump)	//com runs too fast, spacebar 2 times
		setJump(dt);

	if(myKeys[KEY_T])	//reset
	{
		Reset();
	}
	

	/** update jump **/
	if(jump)
		Jump(dt);
	

	/** mouse **/
	Yaw(dt);
	Pitch(dt);
}
void AaMazeInBear_protCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void AWeaponEssentialsCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// Jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void AHeroesAndEmpiresCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
Ejemplo n.º 17
0
static void EndForStmt( void )
{
    DropContinueLabel();
    if( BlockStack->inc_var ) {
        AddStmt( BlockStack->inc_var );
    }
    Jump( BlockStack->top_label );
}
void AAITrainingStreamCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void AUnrealMyoProjectCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void ARewindableReplayDemoCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
Ejemplo n.º 21
0
void Animal::GetDamage(float damage)
{
	m_ClockAnimationDmg.restart();
	Jump();
	if (rand() % 100 > 66)
		Sound::Play(Sound::FLESH_IMPACT);
	Character::GetDamage(damage);
}
Ejemplo n.º 22
0
/**
 * Handler for when a touch input begins.
 */
void AMutagenPlayer::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void AAssignment_1Character::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void AUNREALPROJEKTCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void ABatteryCollectorCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
Ejemplo n.º 26
0
// Immediately jump off of our ladder, if we're on one
void CCSBot::GetOffLadder()
{
	if (IsUsingLadder())
	{
		Jump(MUST_JUMP);
		DestroyPath();
	}
}
void ATLSkillsTreeCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}
void ADefyingGravityCharacter::TouchStarted(const ETouchIndex::Type FingerIndex, const FVector Location)
{

	// jump on any touch
	Jump();
	

}
void CPlayerBase::UpdateJumpState() {
	PROFILE_FUNCTION("update jump state base");
	if (!canJump()) return;
	if (controller->JumpButtonBecomesPressed()) {
		logic_manager->throwEvent(logic_manager->OnJump, "");
		Jump();
	}
}
void AThirdPersonNeuronCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	// jump, but only on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}