コード例 #1
0
ファイル: FPS_Camera.cpp プロジェクト: Mamama22/Framework-C-
void FPS_Cam::UpdateInput(double dt)	//update if inputs available
{
	/* Strafe */
	if (CU::input.IsKeyPressed(Input::A) && !CU::input.IsKeyPressed(Input::D))
	{
		Strafe(-dt);
	}

	if (!CU::input.IsKeyPressed(Input::A) && CU::input.IsKeyPressed(Input::D))
	{
		Strafe(dt);
	}

	/* walk */
	if (CU::input.IsKeyPressed(Input::W) && !CU::input.IsKeyPressed(Input::S))
	{
		Walk(dt);
	}

	if (!CU::input.IsKeyPressed(Input::W) && CU::input.IsKeyPressed(Input::S))
	{
		Walk(-dt);
	}

	/* Fly */
	if (CU::input.IsKeyPressed(Input::K))
	{
		Fly(dt);
	}
	else if (CU::input.IsKeyPressed(Input::L))
	{
		Fly(-dt);
	}
}
コード例 #2
0
ファイル: Camera3.cpp プロジェクト: barryHub20/SP3
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);
}
コード例 #3
0
ファイル: Script.c プロジェクト: Rocket-Fish/openclonk
private func Construction()
{
    // Add effect for the behavior of the bat.
    AddEffect("CoreBehavior", this, 100, 1, this);
    // Start flying.
    Fly();
    // Some bats don't stick to the swarm and start their own.
    if (!Random(100))
        MakeExpat(true);
    return _inherited(...);
}
コード例 #4
0
ファイル: bird.cpp プロジェクト: Modanung/Finchy
void Bird::HandleUpdate(StringHash eventType, VariantMap &eventData)
{
    if (dead_ && GetPosition().y_ < -5.0f) Disable();

    float timeStep = eventData[SceneUpdate::P_TIMESTEP].GetFloat();
    if (sinceSpeciesSet_ < morphTime_){
        Morph();
    }
    sinceSpeciesSet_ += timeStep;

    if (sinceStateChange_ > stateDuration_){
        switch (state_) {
        case BirdState::Flying: {
            SetState(BirdState::Landing);
        } break;
        case BirdState::Standing: {
            SetState(BirdState::Flying);
        } break;
        default:
            break;
        }
    }
    if(!(first_ && state_ == BirdState::Standing)) sinceStateChange_ += timeStep;

    switch (state_) {
    case BirdState::Flying: {
        Fly(timeStep);
    } break;
    case BirdState::Landing: {
        Land(timeStep);
    } break;
    case BirdState::Standing: {
        Stand(timeStep);
    } break;
    default:
        break;
    }

    //Move bird
    rootNode_->Translate(velocity_*timeStep, TS_WORLD);

    //Update rotation in accordance with the birds movement.
    if (velocity_.Length() > 0.01f){
        Quaternion rotation = rootNode_->GetWorldRotation();
        Quaternion aimRotation = rotation;
        aimRotation.FromLookRotation(velocity_);
        rootNode_->SetRotation(rotation.Slerp(aimRotation, 2.0f * timeStep * velocity_.Length()));
    }
}
コード例 #5
0
void EulerCamera::Jumping(double fTimePassed)
{
	curr_time += fTimePassed;
	if (jump_count == 12)
		phase = false;

	if (curr_time - old_time > (0.005f))
	{
		if (phase == true)
		{
			Fly(0.02);
			jump_count++;
		}
		else
		{
			Fly(-0.03);
			jump_count--;
			if (jump_count == 4) jumping = false;
		}
		old_time = curr_time;
	}

	UpdateViewMatrix();
}
コード例 #6
0
ファイル: drone.c プロジェクト: JoePeacock/drone-simulator
void *StartDrone(void *vd) {
  Drone *d = vd;
  while (1) {
    switch(d->current_state) {
      case READY: TakeOff(d);
      case IN_FLIGHT: Fly(d);
      case ARRIVED: LandDrone(d);
      case DELIVERING: DeliverPackage(d);
      case DONE: return 0;
      case FAILED: return 0;
      case TAKING_OFF: ;
      case TAKEOFF_QUEUE: ;
      case FLIGHT_EVADING: ;
      case LANDING: ;
    }
  }
  return 0;
}
コード例 #7
0
ファイル: G_01C01.CPP プロジェクト: crespo2014/cpp-lib
DWORD CViewGame::ThreadRenderScene()
{
	float factor=4;
	glClearColor(0.0f,0.0f,0.0f,1.0f);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glPushMatrix();
	glColor3ub(255,0,0);

	/*
	glColor3ub(255,0,0);
	glBegin(GL_LINE_LOOP);
	for (int i=0;i<360;i+=45)
	{
		glVertex3d(Game_ColX+0.05*cos(i),Game_ColY+0.05*sin(i),Game_ColZ);
	}
	glEnd();
	*/

	Fly();
	glFinish();
	SwapBuffer();
	glPopMatrix();
	return 0;
}
コード例 #8
0
/*** Procesamiento de la lógica del juego ***/
void Logic( float elapsed )
{
    
//    ACC = MulVector(ACC, 5);

    vTerrain = GetHeight( &terrain , cam.pos.x, cam.pos.z ) + altura;
  //  sprintf(fpstex, "%d fps", CalculateFPS(elapsed));
    
    /*Cámara*/
    
    
    // correr
    if (Brun && (cam.pos.y <= vTerrain || under)){
        //  MulVector(VEL, 1.5f);
        run = 3.5f;
    }
    else if (Brun == GL_FALSE && (cam.pos.y <= vTerrain || under)){
        run = 1.0f;
    }
    
    // confirma si esta debajo del agua
    if (cam.pos.y <= vWater)
        under = GL_TRUE;
    else
        under = GL_FALSE;
    
    
    
    //debajo del agua
    
    if (under){
        velocityAgua   = 0.3f;
        
        if (abs(VEL.x) <velocity * 0.3){
            //VEL.x = 10.0;
            ACC.x = 0.0f; //aqui agrego la corriente
        }
        else
            ACC.x = 0.0f;

    }
    else{
        velocityAgua   = 1.0f;
//        VEL.z = 150.0f;
        ACC.x = 0.0f;
        VEL.x = 0.0f;
    }
           
    
    /*
     //bool
(runState ? 0.5f : 1.0f)
     */
 
    if( cam.walk ){
        //VEL.z = velocity * run * velocityAgua;
        Walk( &cam,velocity * run * velocityAgua * elapsed, GL_TRUE);
    }
    if( cam.walkinv ){
        //VEL.z = -velocity * 0.5 * run  * velocityAgua;
        Walk( &cam, -velocity * 0.5 * run  * velocityAgua* elapsed, GL_TRUE);
    }
    if( cam.strafe ){
        //VEL.x = velocity * 0.8 * run * velocityAgua;
        Strafe( &cam, velocity * 0.8 * run * velocityAgua * elapsed, GL_TRUE);
    }    
    if( cam.strafeinv ){
       // VEL.x = -velocity * 0.8 * run * velocityAgua;
        Strafe( &cam, -velocity * 0.8 * run * velocityAgua * elapsed, GL_TRUE);
	}
    
    
/*
    if( cam.walk ){
        VEL.z = velocity * run * velocityAgua;
        Walk( &cam,VEL.z * elapsed, GL_TRUE);
    }else if (cam.pos.y <= vTerrain)
        VEL.z = 0.0f;
    
    if( cam.walkinv ){
        VEL.z = -velocity * run  * velocityAgua;
        Walk( &cam,VEL.z * elapsed, GL_TRUE);
    }else if (cam.pos.y <= vTerrain)
        VEL.z = 0.0f;
    
    if( cam.strafe ){
        VEL.x = velocity * run * velocityAgua;
        Strafe( &cam, VEL.x * elapsed, GL_TRUE);
    }else if (cam.pos.y <= vTerrain)
        VEL.x = 0.0f;
    
    if( cam.strafeinv ){
        VEL.x = -velocity * run * velocityAgua;
        Strafe( &cam, VEL.x * elapsed, GL_TRUE);
	}else if (cam.pos.y <= vTerrain)
        VEL.x = 0.0f;
    
  */
    
    //  LOCALIZACION EN MAPA
    dotX = mapWidth * (cam.pos.x / ( 64.0f * 50.0f));
	dotZ = mapHeight * (cam.pos.z / ( 64.0f * 50.0f));

	
    

    
    //fisicas
    VEL = SumVector ( VEL, MulVector ( ACC , elapsed ) );
    //POS = SumVector ( POS, MulVector ( VEL , elapsed ) );

    cam.pos.x = ( cam.pos.x + (VEL.x * elapsed ) );
    //cam.pos.y = ( cam.pos.y + (VEL.y * elapsed ) );
    // caidas y corriente
    
    
    if (under){
        cam.pos.y = cam.pos.y + (VEL.y * 0.03 * run * elapsed );
        cam.pos.x = cam.pos.x + (VEL.x * elapsed);
    }
    else{
        cam.pos.y = cam.pos.y + (VEL.y * velocityAgua * run * elapsed );
        //cam.pos.z = cam.pos.z + (VEL.z * elapsed);
    }
    
     
     
    if (jump && cam.pos.y<= vTerrain) {
        VEL.y = 40.0f;
        jump = GL_FALSE;
    }else if (jump && (cam.pos.y <= vWater + (altura * 0.1)) ){
        
            // VEL.x = -velocity * 0.8 * run * velocityAgua;
            Fly( &cam, velocity * 0.2 * run * elapsed, GL_TRUE);
            VEL.y = 0.0f;
        if (cam.pos.y > vWater)
            cam.pos.y = vWater + (altura * 0.1f);
        
        /*
        if (cam.pos.y  > vWater -  altura){
            VEL.y = 0.0f;
            cam.pos.y = vWater;

}*/

    }
//OXIGENO
    
    if ((( (Brun && (cam.walk || cam.walkinv || cam.strafe || cam.strafeinv)))  || under) && !oxIn)
        ox -= elapsed;
    else
        ox += 0.2 * elapsed;
    
    if ( ox < 0.0f || oxIn)
        oxIn = GL_FALSE;
    
    if (ox < 0.0f) {
        oxIn = GL_FALSE;
        ox = 0.0f;
    }
    if (ox > oxlevel){
        oxIn = GL_FALSE;
        ox = oxlevel;
    }
    
    
    
//ATAQUES CON LA ESPADA...
    if (atk1){
        if (angX > -70) {
        angX -= 360.0f* elapsed;
        }
        
        if (angZ < 90) {
            angZ += 360.0f* elapsed;
        }else{
        
        angX=0.0f;
        angZ = 0.0f;
            atk1= GL_FALSE;
            
        }
        /*
        if (angZ > 500) {
            angZ -= 360.0f* elapsed;
        }*/



    }
    
    //mueve textura
    movWater +=  0.4f * (elapsed);

    
    
    //no sobrepasa el limite del suelo
    if (cam.pos.y <= vTerrain)
        cam.pos.y = vTerrain;
    
    
    
	
}
コード例 #9
0
 void OnReachWP(uint32 iWaypointId, bool bForwards)
 {
     switch(iWaypointId)
     {
     case 1:
         {
             _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_WANTEDWP);
             _unit->GetAIInterface()->setWaypointToMove(2);
             Fly();
         }break;
     case 2:
         {
             _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_WANTEDWP);
             _unit->GetAIInterface()->setWaypointToMove(3);
         }break;
     case 3:
         {
             _unit->GetAIInterface()->m_canMove = false;
             _unit->GetAIInterface()->SetAllowedToEnterCombat(true);
             _unit->GetAIInterface()->setCurrentAgent(AGENT_SPELL);
             //_unit->m_pacified--;
             _unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
             _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
             _unit->GetAIInterface()->setWaypointToMove(0);
             WorldPacket data(SMSG_MOVE_SET_HOVER, 13);
             data << _unit->GetNewGUID();
             data << uint32(0);
             _unit->SendMessageToSet(&data, false);
             m_currentWP = 3;
         }break;
     case 8:
         {
             _unit->GetAIInterface()->SetAllowedToEnterCombat(true);
             _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
             _unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
             _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
             _unit->GetAIInterface()->setWaypointToMove(0);
             /*_unit->m_pacified--;
             if(_unit->m_pacified > 0)
                 _unit->m_pacified--;*/
             WorldPacket data(SMSG_MOVE_UNSET_HOVER, 13);
             data << _unit->GetNewGUID();
             data << uint32(0);
             _unit->SendMessageToSet(&data, false);
             Land();
         }break;
     default:
         {
             _unit->GetAIInterface()->m_canMove = false;
             _unit->GetAIInterface()->SetAllowedToEnterCombat(true);
             _unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
             _unit->GetAIInterface()->setMoveType(MOVEMENTTYPE_DONTMOVEWP);
             _unit->GetAIInterface()->setWaypointToMove(0);
             WorldPacket data(SMSG_MOVE_SET_HOVER, 13);
             data << _unit->GetNewGUID();
             data << uint32(0);
             _unit->SendMessageToSet(&data, false);
             //_unit->m_pacified--;
         }break;
     };
 }