コード例 #1
0
ファイル: solid_model.cpp プロジェクト: LANTZT/feelpp-book
void
runApplicationSolid()
{
    typedef FeelModels::SolidMechanics< Simplex<FEELPP_DIM,1>,
                                        Lagrange<OrderDisp, Vectorial,Continuous,PointSetFekete> > model_type;
    auto SM = model_type::New("solid");

    if ( SM->isStationary() )
    {
        bool algoQuasiStatic = boption(_name="solve-quasi-static");
        if ( !algoQuasiStatic )
        {
            SM->init();
            SM->printAndSaveInfo();
            SM->solve();
            SM->exportResults();
        }
        else
        {
            SM->init();
            SM->printAndSaveInfo();

            std::string variableSymbol = soption(_name="solve-quasi-static.variable-symbol");
            CHECK( SM->modelProperties().parameters().find(variableSymbol) != SM->modelProperties().parameters().end() ) << "not find symbol " << variableSymbol;
            double valueFinal = SM->modelProperties().parameters().find(variableSymbol)->second.value();
            double valueInitial = doption(_name="solve-quasi-static.variable-initial");
            double valueStep = doption(_name="solve-quasi-static.variable-step");
            int cptNeed = std::abs(valueFinal-valueInitial)/valueStep;
            double currentParam = valueInitial;

            std::string namefileVariableParameters = (fs::path(SM->rootRepository()) / fs::path("paramters-done.data")).string();

            std::string saveType = soption(_name="solve-quasi-static.save.file-format");

            int cptCurrent=1;
            if ( SM->doRestart() )
            {
                std::ifstream fileParameter(namefileVariableParameters.c_str());
                while ( ! fileParameter.eof() ) { fileParameter >> cptCurrent >> currentParam; }
                fileParameter.close();

                SM->fieldDisplacement().load(_path=SM->rootRepository()+"/"+(boost::format("uSol.field-%1%") %cptCurrent ).str(),
                                             _type=saveType );
                if ( SM->useDisplacementPressureFormulation() )
                    SM->fieldPressure().load(_path=SM->rootRepository()+"/"+(boost::format("pSol.field-%1%") %cptCurrent ).str(),
                                             _type=saveType );

                SM->restartExporters(cptCurrent);
                ++cptCurrent;
            }
            else
            {
コード例 #2
0
ファイル: Player.cpp プロジェクト: fuzzwaz/TheElderScrolls2D
void Player::render()
{
    SDL_Rect* test_Rectangle = new SDL_Rect;
    test_Rectangle->x = 0;
    test_Rectangle->y = 0;
    test_Rectangle->w = width;
    test_Rectangle->h = height;
    
    

    if (!isStationary() && (time_movement.getTicks() > walkingAnimationDelta))
    {
        movementCounter++;
        if (movementCounter > 6) {movementCounter = 1;}
        setAnimation(currentAnimation, movementCounter);
        time_movement.start();
    }
    
    texture->render(posX, posY, test_Rectangle);

}
コード例 #3
0
ファイル: Player.cpp プロジェクト: fuzzwaz/TheElderScrolls2D
void Player::handleEvent(SDL_Event& e)
{
    //If a key was pressed
    if( e.type == SDL_KEYDOWN && e.key.repeat == 0 )
    {
        //Adjust the velocity
        switch( e.key.keysym.sym )
        {
            case SDLK_a:
                velX -= velocity;
                if (isStationary()){setAnimation(a_PlayerMovement::LEFT_SIDE);}
                if (!time_movement.isStarted()){time_movement.start();}
                direction[a_Directions::LEFT] = true;
                break;
            case SDLK_d:
                velX += velocity;
                if (isStationary()){setAnimation(a_PlayerMovement::RIGHT_SIDE);}
                if (!time_movement.isStarted()){time_movement.start();}
                direction[a_Directions::RIGHT] = true;
                break;
            case SDLK_w:
                velY -= velocity;
                if (isStationary()){setAnimation(a_PlayerMovement::FORWARD);}
                if (!time_movement.isStarted()){time_movement.start();}
                direction[a_Directions::UP] = true;
                break;
            case SDLK_s:
                velY += velocity;
                if (isStationary()){setAnimation(a_PlayerMovement::BACKWARDS);}
                if (!time_movement.isStarted()){time_movement.start();}
                direction[a_Directions::DOWN] = true;
                break;
        }
    }
    //If a key was released
    else if( e.type == SDL_KEYUP && e.key.repeat == 0 )         {
        //Adjust the velocity
        switch( e.key.keysym.sym )
        {
            case SDLK_a:
                velX += velocity;
                direction[a_Directions::LEFT] = false;
                if (isStationary()){time_movement.stop();}
                changeDirection();
                break;
            case SDLK_d:
                velX -= velocity;
                direction[a_Directions::RIGHT] = false;
                if (isStationary()){time_movement.stop();}
                changeDirection();
                break;
            case SDLK_w:
                velY += velocity;
                direction[a_Directions::UP] = false;
                if (isStationary()){time_movement.stop();}
                changeDirection();
                break;
            case SDLK_s:
                velY -= velocity;
                direction[a_Directions::DOWN] = false;
                if (isStationary()){time_movement.stop();}
                changeDirection();
                break;
        }
    }
}