Exemple #1
0
void CMainMenu::Update(const SUIInput& a_rInput)
{
    if (m_GoingIntoGame)
    {
        float half = CPostEffects::GameStartTime / 2.0f;
        m_CurrentTime += twTime->GetDeltaTime();

        float value = m_CurrentTime / half;
        ((triebWerk::CUIDrawable*)(m_pBackground->GetDrawable()))->m_Material.m_ConstantBuffer.SetValueInBuffer(4, &value);

        if (m_CurrentTime >= half)
        {
            twSceneManager->SetActiveScene("Game");
            m_GoingIntoGame = false;
            m_CurrentTime = 0.0f;
        }

        return;
    }

    else if (m_LerpToExtras) LerpToExtras();
    else if (m_LerpFromExtras) LerpFromExtras();

    if (CGameInfo::Instance().m_Menu == EMenus::Main)
    {
        ((triebWerk::CFontDrawable*)m_pTextExtras->GetDrawable())->m_pText->SetText("Extras");
        CheckInput(a_rInput);
    }

    UpdateGraphics();
}
Exemple #2
0
void CPU::Update()
{
	const int MAXCYCLES = 70221;
	int cyclesThisUpdate = 0;

	while (cyclesThisUpdate < MAXCYCLES)
	{

		if (shouldDisableInterrupts)
		{
			interruptMasterEnable = false;
			shouldDisableInterrupts = false;
		}

		if (shouldEnableInterrupts)
		{
			interruptMasterEnable = true;
			shouldEnableInterrupts = false;
		}

		Instruction *instruction = InvokeInstruction(ReadByte(PC));
		int cycles = instruction->GetDuration();

		cyclesThisUpdate += cycles;
		UpdateTimers(cycles);
		UpdateGraphics(cycles);
		HandleInterrupts();
	}
}
bool PointStarVlist::BeginDrawState (const QVector &center, const Vector & velocity, const Vector & torque, bool roll, bool yawpitch, int whichTexture) {
    UpdateGraphics();
    static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false"));
    GFXColorMaterial(AMBIENT|DIFFUSE);
    bool ret=false;
    if (StarStreaks) {
        Matrix rollMatrix;
        static float velstreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_scale","5"));
        static float minstreak= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_min","1"));
        static float fov_smoothing=XMLSupport::parse_float(vs_config->getVariable("graphics","warp.fovlink.smoothing",".4"));
        float fov_smoot = pow(double(fov_smoothing),GetElapsedTime());
        Vector vel (-velocity*velstreakscale);
        float speed = vel.Magnitude();

        if ((smoothstreak>=minstreak||vel.MagnitudeSquared()>=minstreak*minstreak)&&(speed>1.0e-7)) {
            ret=true;
            vel*=1./speed;
            speed = fov_smoot*speed + (1-fov_smoot)*smoothstreak;

            if (speed<minstreak) speed=minstreak;
            static float streakcap  = XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_max","100"));
            if (speed>streakcap) {
                speed=streakcap;
            }
            vel=vel*speed;
            smoothstreak=speed;
            GFXColorVertex * v = vlist->BeginMutate(0)->colors;
            int numvertices = vlist->GetNumVertices();

            static float torquestreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","torque_star_streak_scale","1"));
            for (int j=0; j<numvertices-1; j+=2) {
                int i=j;
//				if (SlowStarStreaks)
//					i=((rand()%numvertices)/2)*2;
                Vector vpoint (v[i+1].x,v[i+1].y,v[i+1].z);
                Vector recenter =(vpoint-center.Cast());
                if (roll) {
                    RotateAxisAngle(rollMatrix,torque,torque.Magnitude()*torquestreakscale*.003);
                    vpoint = Transform(rollMatrix,recenter)+center.Cast();
                }
                v[i].x=vpoint.i-vel.i;
                v[i].y=vpoint.j-vel.j;
                v[i].z=vpoint.k-vel.k;
//				static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05"));
//				if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices)
//					break;
            }
            vlist->EndMutate();
        }
    }
    if (ret) {
        vlist->LoadDrawState();
        vlist->BeginDrawState();
    } else {
        nonstretchvlist->LoadDrawState();
        nonstretchvlist->BeginDrawState();
    }
    return ret;
}
bool SpriteStarVlist::BeginDrawState(const QVector &center, const Vector &velocity, const Vector & torque, bool roll, bool yawpitch, int whichTex) {

    UpdateGraphics();
    GFXEnable(TEXTURE0);
    decal[whichTex]->MakeActive();
    GFXDisable(CULLFACE);
    GFXColorMaterial(AMBIENT|DIFFUSE);
    vlist[whichTex]->LoadDrawState();
    vlist[whichTex]->BeginDrawState();
    return false;
}
	void PTrackManager::CheckForFinishLine()
	{
		// Check if a finish line needs to be added
		if (track->trk->length >= TotalLength())
		{
			int segBefore = track->trk->nseg;
			track->AddFinishLine();
			int segAfter = track->trk->nseg;

			// Append graphics if a finish line was added
			if (segAfter > segBefore)
			{
				if (raceManager->raceEngineInfo.displayMode == RM_DISP_MODE_NORMAL)
					UpdateGraphics();
			}
		}
	}
	void PTrackManager::Update(bool adaptive, float skillLevel)
	{
		// Prevent cars driving off the back of the track
		CorrectCars();

		if (trackType == PTrackType::PROCEDURAL)
		{
			// If the current leading car is a given distance from the end, generate a new segment
			if (LeadingCar()->pub.trkPos.seg->id + MAX_SEGS_FROM_END >= track->GetEnd()->id) // If a new segment needs to be generated
			{
				if (!adaptive) // Generate random segment if not adaptive
					AddSegment(segFactory->CreateRandomSeg(track->state.curSegIndex));
				else // Otherwise, generate segment taking into account skill level
					GenerateAdaptiveSegment(skillLevel);

				// Update graphical description
				if (raceManager->raceEngineInfo.displayMode == RM_DISP_MODE_NORMAL)
					UpdateGraphics();

				// Check if a finish line needs to be added
				CheckForFinishLine();
			}
		}
	}
Exemple #7
0
void CAR::Update(double dt)
{
	UpdateGraphics();
	UpdateSounds(dt);
}
Exemple #8
0
int C4GameObjects::Load(C4Group &hGroup, bool fKeepInactive) {
  Clear(!fKeepInactive);

  // Load data component
  StdStrBuf Source;
  if (!hGroup.LoadEntryString(C4CFN_ScenarioObjects, Source)) return 0;

  // Compile
  StdStrBuf Name = hGroup.GetFullName() + DirSep C4CFN_ScenarioObjects;
  if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(mkParAdapt(*this, false),
                                                  Source, Name.getData()))
    return 0;

  // Process objects
  C4ObjectLink *cLnk = nullptr;
  C4Object *pObj = nullptr;
  bool fObjectNumberCollision = false;
  int32_t iMaxObjectNumber = 0;
  for (cLnk = Last; cLnk; cLnk = cLnk->Prev) {
    C4Object *pObj = cLnk->Obj;
    // check object number collision with inactive list
    if (fKeepInactive) {
      for (C4ObjectLink *clnk = InactiveObjects.First; clnk; clnk = clnk->Next)
        if (clnk->Obj->Number == pObj->Number) fObjectNumberCollision = true;
    }
    // keep track of numbers
    iMaxObjectNumber = Max<long>(iMaxObjectNumber, pObj->Number);
    // add to list of backobjects
    if (pObj->Category & C4D_Background)
      Game.BackObjects.Add(pObj, C4ObjectList::stMain, this);
    // add to list of foreobjects
    if (pObj->Category & C4D_Foreground)
      Game.ForeObjects.Add(pObj, C4ObjectList::stMain, this);
    // Unterminate end
  }

  // Denumerate pointers
  // if object numbers collideded, numbers will be adjusted afterwards
  // so fake inactive object list empty meanwhile
  C4ObjectLink *pInFirst = nullptr;
  if (fObjectNumberCollision) {
    pInFirst = InactiveObjects.First;
    InactiveObjects.First = NULL;
  }
  // denumerate pointers
  Denumerate();
  // update object enumeration index now, because calls like UpdateTransferZone
  // might create objects
  Game.ObjectEnumerationIndex =
      Max(Game.ObjectEnumerationIndex, iMaxObjectNumber);
  // end faking and adjust object numbers
  if (fObjectNumberCollision) {
    InactiveObjects.First = pInFirst;
    // simply renumber all inactive objects
    for (cLnk = InactiveObjects.First; cLnk; cLnk = cLnk->Next)
      if ((pObj = cLnk->Obj)->Status)
        pObj->Number = ++Game.ObjectEnumerationIndex;
  }

  // special checks:
  // -contained/contents-consistency
  // -StaticBack-objects zero speed
  for (cLnk = First; cLnk; cLnk = cLnk->Next)
    if ((pObj = cLnk->Obj)->Status) {
      // staticback must not have speed
      if (pObj->Category & C4D_StaticBack) {
        pObj->xdir = pObj->ydir = 0;
      }
      // contained must be in contents list
      if (pObj->Contained)
        if (!pObj->Contained->Contents.GetLink(pObj)) {
          DebugLogF(
              "Error in Objects.txt: Container of #%d is #%d, but not found in "
              "contents list!",
              pObj->Number, pObj->Contained->Number);
          pObj->Contained->Contents.Add(pObj, C4ObjectList::stContents);
        }
      // all contents must have contained set; otherwise, remove them!
      C4Object *pObj2;
      for (C4ObjectLink *cLnkCont = pObj->Contents.First; cLnkCont;
           cLnkCont = cLnkCont->Next) {
        // check double links
        if (pObj->Contents.GetLink(cLnkCont->Obj) != cLnkCont) {
          DebugLogF("Error in Objects.txt: Double containment of #%d by #%d!",
                    cLnkCont->Obj->Number, pObj->Number);
          // this remove-call will only remove the previous (dobuled) link, so
          // cLnkCont should be save
          pObj->Contents.Remove(cLnkCont->Obj);
          // contents checked already
          continue;
        }
        // check contents/contained-relation
        if ((pObj2 = cLnkCont->Obj)->Status)
          if (pObj2->Contained != pObj) {
            DebugLogF(
                "Error in Objects.txt: Object #%d not in container #%d as "
                "referenced!",
                pObj2->Number, pObj->Number);
            pObj2->Contained = pObj;
          }
      }
    }
  // sort out inactive objects
  C4ObjectLink *cLnkNext;
  for (cLnk = First; cLnk; cLnk = cLnkNext) {
    cLnkNext = cLnk->Next;
    if (cLnk->Obj->Status == C4OS_INACTIVE) {
      if (cLnk->Prev)
        cLnk->Prev->Next = cLnkNext;
      else
        First = cLnkNext;
      if (cLnkNext)
        cLnkNext->Prev = cLnk->Prev;
      else
        Last = cLnk->Prev;
      if (cLnk->Prev = InactiveObjects.Last)
        InactiveObjects.Last->Next = cLnk;
      else
        InactiveObjects.First = cLnk;
      InactiveObjects.Last = cLnk;
      cLnk->Next = NULL;
      Mass -= pObj->Mass;
    }
  }

  {
    C4DebugRecOff DBGRECOFF;  // - script callbacks that would kill
                              // DebugRec-sync for runtime start
    // update graphics
    UpdateGraphics(false);
    // Update faces
    UpdateFaces(false);
    // Update ocf
    SetOCF();
  }

  // make sure list is sorted by category - after sorting out inactives, because
  // inactives aren't sorted into the main list
  FixObjectOrder();

  // Sectors.Dump();

  // misc updates
  for (cLnk = First; cLnk; cLnk = cLnk->Next)
    if ((pObj = cLnk->Obj)->Status) {
      // add to plrview
      pObj->PlrFoWActualize();
      // update flipdir (for old objects.txt with no flipdir defined)
      // assigns Action.DrawDir as well
      pObj->UpdateFlipDir();
    }
  // Done
  return ObjectCount();
}