예제 #1
0
CPlayer::CPlayer(const CPlayer &player) :
CVorticonSpriteObject(player.mp_Map,
                      player.getXPosition(), player.getYPosition(),
                      OBJ_PLAYER, player.getSpriteVariantId() ),
pjumpupspeed_decrease(player.pjumpupspeed_decrease),
mp_levels_completed(player.mp_levels_completed),
mp_option(g_pBehaviorEngine->m_option)
{
    //mp_object = player.mp_object;
    canbezapped = true;
    m_index = 0;


    pjumping = PNOJUMP;
    pfalling = false;
    psemisliding = false;
    psliding = false;
    ppogostick = false;
    pslowingdown = false;
    m_playingmode = WORLDMAP;
    playpushed_decreasetimer = 0;


    // Set every value in the class to zero.
    memset(&inventory, 0, sizeof(stInventory));
    setDefaultStartValues();
    setDatatoZero();
    pinertia_y = 0;
}
예제 #2
0
///
// Initialization Part
///
CPlayer::CPlayer(bool *mpLevelCompleted,
                 CMap &map, const int sprVar) :
CVorticonSpriteObject(&map, 0, 0, OBJ_PLAYER, sprVar),
pjumpupspeed_decrease(g_pBehaviorEngine->getPhysicsSettings().player.defaultjumpupdecreasespeed),
mp_levels_completed(mpLevelCompleted),
mp_option(g_pBehaviorEngine->m_option)
{
    canbezapped = true;
    m_index = 0;


    pjumping = PNOJUMP;
    pfalling = false;
    psemisliding = false;
    psliding = false;
    ppogostick = false;
    pslowingdown = false;
    m_playingmode = WORLDMAP;


    // Set every value in the class to zero.
    memset(&inventory, 0, sizeof(stInventory));
    setDefaultStartValues();
    setDatatoZero();
}
예제 #3
0
CPlayer& CPlayer::operator=(const CPlayer &player)
{
    pjumpupspeed_decrease = player.pjumpupspeed_decrease;
    mp_levels_completed = player.mp_levels_completed;
    mp_option = g_pBehaviorEngine->m_option;
    canbezapped = true;
    m_index = 0;

    pjumping = PNOJUMP;
    pfalling = false;
    psemisliding = false;
    psliding = false;
    ppogostick = false;
    pslowingdown = false;
    m_playingmode = WORLDMAP;


    // Set every value in the class to zero.
    memset(&inventory, 0, sizeof(stInventory));
    setDefaultStartValues();
    setDatatoZero();
    
    return *this;
}
예제 #4
0
/***************************************************
Functions for FMI for Model Exchange
****************************************************/
fmiComponent fmiInstantiateModel(fmiString instanceName, fmiString GUID, fmiCallbackFunctions functions, fmiBoolean loggingOn)
{
  ModelInstance* comp;
  if (!functions.logger)
    return NULL;
  if (!functions.allocateMemory || !functions.freeMemory){
    functions.logger(NULL, instanceName, fmiError, "error",
        "fmiInstantiateModel: Missing callback function.");
    return NULL;
  }
  if (!instanceName || strlen(instanceName)==0) {
    functions.logger(NULL, instanceName, fmiWarning, "Warning",
        "fmiInstantiateModel: Missing instance name.");
  }
  if (strcmp(GUID, MODEL_GUID) != 0) {
    functions.logger(NULL, instanceName, fmiError, "error",
        "fmiInstantiateModel: Wrong GUID %s. Expected %s.", GUID, MODEL_GUID);
    return NULL;
  }
  comp = (ModelInstance *)functions.allocateMemory(1, sizeof(ModelInstance));
  if (comp) {
    DATA* fmudata = NULL;
	MODEL_DATA* modelData = NULL;
	SIMULATION_INFO* simInfo = NULL;
	threadData_t *threadData = NULL;

    comp->functions = functions;
    comp->loggingOn = loggingOn;
    comp->state = modelInstantiated;
    comp->instanceName = functions.allocateMemory(1 + strlen(instanceName), sizeof(char));
    comp->GUID = functions.allocateMemory(1 + strlen(GUID), sizeof(char));
    /* Cannot use functions.allocateMemory since the pointer might not be stored on the stack of the parent */
    fmudata = (DATA *)functions.allocateMemory(1, sizeof(DATA));
    modelData = (MODEL_DATA *)functions.allocateMemory(1, sizeof(MODEL_DATA));
    simInfo = (SIMULATION_INFO *)functions.allocateMemory(1, sizeof(SIMULATION_INFO));
    fmudata->modelData = modelData;
    fmudata->simulationInfo = simInfo;


    threadData = (threadData_t *)functions.allocateMemory(1, sizeof(threadData_t));
    memset(threadData, 0, sizeof(threadData_t));
    /*
    pthread_key_create(&fmu1_thread_data_key,NULL);
    pthread_setspecific(fmu1_thread_data_key, threadData);
    */

    comp->threadData = threadData;
    comp->fmuData = fmudata;

    if (!comp->fmuData) {
      functions.logger(NULL, instanceName, fmiError, "error",
          "fmiInstantiateModel: Error: Could not initialize the global data structure file.");
      return NULL;
    }
  }
  if (!comp || !comp->instanceName || !comp->GUID) {
    functions.logger(NULL, instanceName, fmiError, "error", "fmiInstantiateModel: Out of memory.");
    return NULL;
  }
  /* intialize modelData */
  fmu1_model_interface_setupDataStruc(comp->fmuData);
  useStream[LOG_STDOUT] = 1;
  useStream[LOG_ASSERT] = 1;
  initializeDataStruc(comp->fmuData, comp->threadData);
  /* setup model data with default start data */
  setDefaultStartValues(comp);
  setAllVarsToStart(comp->fmuData);
  setAllParamsToStart(comp->fmuData);
  comp->fmuData->callback->read_input_fmu(comp->fmuData->modelData, comp->fmuData->simulationInfo);
  modelInfoInit(&(comp->fmuData->modelData->modelDataXml));

  strcpy((char*)comp->instanceName, (const char*)instanceName);
  strcpy((char*)comp->GUID, (const char*)GUID);

  /* read input vars */
  //input_function(comp->fmuData);
  /* initial sample and delay before initial the system */
  comp->fmuData->callback->callExternalObjectConstructors(comp->fmuData, comp->threadData);
  /* allocate memory for non-linear system solvers */
  initializeNonlinearSystems(comp->fmuData, comp->threadData);
  /* allocate memory for non-linear system solvers */
  initializeLinearSystems(comp->fmuData, comp->threadData);
  /* allocate memory for mixed system solvers */
  initializeMixedSystems(comp->fmuData, comp->threadData);
  /* allocate memory for state selection */
  initializeStateSetJacobians(comp->fmuData, comp->threadData);

  return comp;
}