コード例 #1
0
void CFirstPersonCameraComponent::Update()
{
	auto pPlayer = CPlayerComponent::GetLocalPlayer();
	auto pPlayerInput = pPlayer->GetPlayerInput();

	// Default on failure is to return a cleanly constructed default matrix.
	Matrix34 newCameraMatrix = Matrix34::Create(Vec3(1.0f), IDENTITY, ZERO);

	if (pPlayerInput)
	{
		// Resolve the entity.
		if (auto pEntity = gEnv->pEntitySystem->GetEntity(m_targetEntityID))
		{
			// It's possible there is no actor to query for eye position, in that case, return a safe default
			// value for an average height person.
			Vec3 localEyePosition { AverageEyePosition };

			// If we are attached to an entity that is an actor we can use their eye position.
			auto pActor = CActorComponent::GetActor(m_targetEntityID);
			if (pActor)
				localEyePosition = pActor->GetLocalEyePos();

			// Apply the player input rotation for this frame, and limit the pitch / yaw movement according to the set max and min values.
			if (pPlayer->GetinteractionState().IsCameraMovementAllowed())
			{
				m_viewPitch -= pPlayerInput->GetMousePitchDelta() - pPlayerInput->GetXiPitchDelta();
				m_viewPitch = clamp_tpl(m_viewPitch, DEG2RAD(g_cvars.m_firstPersonCameraPitchMin), DEG2RAD(g_cvars.m_firstPersonCameraPitchMax));
			}

			// Pose is based on entity position and the eye position.
			// We will use the rotation of the entity as a base, and apply pitch based on our own reckoning.
			const Vec3 position = pEntity->GetPos() + localEyePosition;
			const Quat rotation = pEntity->GetRotation() * Quat(Ang3(m_viewPitch, 0.0f, 0.0f));
			newCameraMatrix = Matrix34::Create(Vec3(1.0f), rotation, position + rotation * m_pCameraManager->GetViewOffset());

#if defined(_DEBUG)
			if (g_cvars.m_firstPersonCameraDebug)
			{
				gEnv->pRenderer->GetIRenderAuxGeom()->DrawSphere(position, 0.04f, ColorB(0, 0, 255, 255));
			}
#endif
		}
	}

	// Store the new matrix for later.
	m_cameraMatrix = newCameraMatrix;
}
コード例 #2
0
ファイル: Raven_Game.cpp プロジェクト: armagone/Logique-Floue
//-------------------------------- Update -------------------------------------
//
//  calls the update function of each entity
//-----------------------------------------------------------------------------
void Raven_Game::Update()
{ 
  //don't update if the user has paused the game
  if (m_bPaused) return;

  m_pGraveMarkers->Update();

  //get any player keyboard input
  GetPlayerInput();
  
  //update all the queued searches in the path manager
  m_pPathManager->UpdateSearches();

  //update any doors
  std::vector<Raven_Door*>::iterator curDoor =m_pMap->GetDoors().begin();
  for (curDoor; curDoor != m_pMap->GetDoors().end(); ++curDoor)
  {
    (*curDoor)->Update();
  }

  //update any current projectiles
  std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin();
  while (curW != m_Projectiles.end())
  {
    //test for any dead projectiles and remove them if necessary
    if (!(*curW)->isDead())
    {
      (*curW)->Update();

      ++curW;
    }
    else
    {    
      delete *curW;

      curW = m_Projectiles.erase(curW);
    }   
  }
  
  //update the bots
  bool bSpawnPossible = true;
  
  std::list<Raven_Bot*>::iterator curBot = m_Bots.begin();
  for (curBot; curBot != m_Bots.end(); ++curBot)
  {
    //if this bot's status is 'respawning' attempt to resurrect it from
    //an unoccupied spawn point
    if ((*curBot)->isSpawning() && bSpawnPossible)
    {
      bSpawnPossible = AttemptToAddBot(*curBot);
    }
    
    //if this bot's status is 'dead' add a grave at its current location 
    //then change its status to 'respawning'
    else if ((*curBot)->isDead())
    {

      //create a grave

		
		GraveMarkers::GraveRecord grave = m_pGraveMarkers->AddGrave((*curBot)->Pos(), (*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId());

		GraveMarkers::GraveRecord* gravePtr = &grave;

		if ((*curBot)->GetWeaponSys()->GetCurrentWeaponId() != 0)
		{
			GetMap()->AddTeam_Giver((*curBot)->GetTeamId(), (*curBot)->GetWeaponSys()->GetCurrentWeaponId(), (*curBot)->Pos(), (*curBot)->GetPathPlanner()->GetClosestNodeToPosition((*curBot)->Pos()), grave);
		}
			

		
		std::list<Raven_Bot*>::iterator curBot2 = m_Bots.begin();
		for (curBot2; curBot2 != m_Bots.end(); ++curBot2)
		{
			//send a message to all my team
			if ((*curBot2)->GetTeamId() == (*curBot)->GetTeamId())
			{
				Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY,
					(*curBot)->ID(),
					(*curBot2)->ID(),
					Msg_IWasKilledAndIHadWeapons,
					(void*)gravePtr);
				
				//debug_con << "Bot " << ttos((*curBot)->ID()) << " : I'm dead : team (" << ttos(gravePtr->teamId) << ") ";
			}
			
		}

      //change its status to spawning
      (*curBot)->SetSpawning();
    }

    //if this bot is alive update it.
    else if ( (*curBot)->isAlive())
    {
      (*curBot)->Update();
    }  
  } 

  //update the triggers
  m_pMap->UpdateTriggerSystem(m_Bots);

  //if the user has requested that the number of bots be decreased, remove
  //one
  if (m_bRemoveABot)
  { 
    if (!m_Bots.empty())
    {
      Raven_Bot* pBot = m_Bots.back();
      if (pBot == m_pSelectedBot)m_pSelectedBot=0;
      NotifyAllBotsOfRemoval(pBot);
      delete m_Bots.back();
      m_Bots.remove(pBot);
      pBot = 0;
    }

    m_bRemoveABot = false;
  }
}
コード例 #3
0
ファイル: game.c プロジェクト: insin/cdogs-wii
int gameloop(void)
{
	struct Buffer *buffer;
	int ticks;
	int c = 0;
	int cmd1, cmd2;
	int done = NO;
	time_t t;
	struct tm *tp;

	buffer = NewBuffer();
	SetClip(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1);

	if (ModuleStatus() != MODULE_OK)
		DisplayMessage(ModuleMessage());

	gameIsPaused = NO;

	missionTime = 0;
	//screenShaking = 0;
	while (!done) {
		frames++;

		Ticks_FrameBegin();

		ticks = Ticks_Synchronize();

		if (gOptions.displaySlices)
			SetColorZero(32, 0, 0);

		DrawScreen(buffer, gPlayer1, gPlayer2);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		if (screenShaking) {
			screenShaking -= ticks;
			if (screenShaking < 0)
				screenShaking = 0;
		}

		debug(D_VERBOSE, "frames... %d\n", frames);

		if (Ticks_TimeElapsed(TICKS_PER_SEC)) {
			fps = frames;
			debug(D_NORMAL, "fps = %d\n", fps);
			frames = 0;

			t = time(NULL);
			tp = localtime(&t);
			timeHours = tp->tm_hour;
			timeMinutes = tp->tm_min;
		}

		if (messageTicks > 0)
			messageTicks -= ticks;

		StatusDisplay();

		if (!gameIsPaused) {
			missionTime += ticks;
			if ((gPlayer1 || gPlayer2) && MissionCompleted()) {
				if (gMission.pickupTime == PICKUP_LIMIT)
					PlaySound(SND_DONE, 0, 255);
				gMission.pickupTime -= ticks;
				if (gMission.pickupTime <= 0)
					done = YES;
			} else
				gMission.pickupTime = PICKUP_LIMIT;
		}

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 32);

		if (gOptions.displaySlices)
			SetColorZero(0, 0, 0);

		CopyToScreen();

		if (!gameIsPaused) {
			if (!gOptions.slowmotion || (frames & 1) == 0) {
				UpdateAllActors(ticks);
				UpdateMobileObjects();

				GetPlayerInput(&cmd1, &cmd2);

				if (gPlayer1 && !PlayerSpecialCommands(
							gPlayer1, cmd1, &gPlayer1Data)) {
					CommandActor(gPlayer1, cmd1);
				}
				if (gPlayer2 && !PlayerSpecialCommands(
							gPlayer2, cmd2, &gPlayer2Data)) {
					CommandActor(gPlayer2, cmd2);
				}

				if (gOptions.badGuys)
					CommandBadGuys();

				UpdateWatches();
			}
		} else {
			GetPlayerInput(&cmd1, &cmd2);
		}

		if (!gPlayer1 && !gPlayer2) {
			done = YES;
			c = 0;
		} else {
			c = HandleKey(&done, cmd1 | cmd2);
		}

		Ticks_FrameEnd();
	}
	free(buffer);

	return c != keyEsc;
}
コード例 #4
0
ファイル: Arena.c プロジェクト: subenji/DoomRPG
// Arena Script
NamedScript MapSpecial void ArenaLoop()
{
    int BonusRandomizer, Buttons, OldButtons;
    bool Ready;
    ArenaSetEnvironment(AEVENT_NONE);
    
    // Arena Loop
    while (true)
    {
        // Stop the script if the Arena is stopped or the Arena activator dies
        if (!ArenaActive || ClassifyActor(Players(ArenaPlayerNumber).TID) & ACTOR_DEAD)
        {
            ArenaStop();
            return;
        }
        
        // Arena HUD
        ArenaDrawHUD();
        
        // Arena Status Handling
        if (ArenaState == ARENA_INTERMISSION)
        {
            BonusRandomizer = Random(-10, ABONUS_MAX - 1);

            ArenaMod = -1;
            ArenaGetBonus(BonusRandomizer);
            ArenaSetEnvironment(AEVENT_NONE);
            ArenaState = ARENA_WAITING;
        }
        else if (ArenaState == ARENA_WAITING)
        {
            Buttons = GetPlayerInput(ArenaPlayerNumber, INPUT_BUTTONS);
            OldButtons = GetPlayerInput(ArenaPlayerNumber, INPUT_OLDBUTTONS);
            Ready = true;
            
            SetHudSize(0, 0, false);
            SetFont("BIGFONT");
            
            if (ArenaPlayerNumber == PlayerNumber())
            {
                if (!Player.InMenu && !Player.InShop && !Player.OutpostMenu)
                {
                    HudMessage("Press \Cd%jS\C- to start the next wave\nPress \Cd%jS\C- to exit the Arena", "+use" , "+speed");
                    EndHudMessage(HUDMSG_PLAIN, 0, "White", 1.5, 0.75, 0.05);
                }
                
                if (Buttons & BT_USE && (!Player.InMenu && !Player.InShop && !Player.OutpostMenu && !Player.CrateOpen) && !Player.MenuBlock)
                {
                    // Check to see if others are still in the menu
                    for (int i = 0; i < MAX_PLAYERS; i++)
                        if (Players(i).InMenu || Players(i).InShop)
                            Ready = false;
                    
                    if (Ready)
                    {
                        ArenaKeyTimer++;
                        ArenaKeyTimerType = AKTIMER_CONTINUE;
                        if (ArenaKeyTimer > ARENA_HOLDTIME)
                        {
                            // Multiplayer Countdown
                            if (InMultiplayer)
                            {
                                SetFont("BIGFONT");
                                for (int i = 3; i > 0; i--)
                                {
                                    HudMessage("%d", i);
                                    EndHudMessageBold(HUDMSG_FADEOUT, 0, "Green", 0.5, 0.5, 0.25, 0.75);
                                    Delay(35);
                                }
                            }
                            
                            ArenaWave++;
                            ArenaState = ARENA_READY;
                        }
                    }
                    else
                    {
                        PrintError("Someone is currently in a menu");
                        ActivatorSound("menu/error", 127);
                    }
                }
                else if (Buttons & BT_SPEED && (!Player.InMenu && !Player.InShop && !Player.OutpostMenu && !Player.CrateOpen))
                {
                    ArenaKeyTimer++;
                    ArenaKeyTimerType = AKTIMER_STOP;
                    if (ArenaKeyTimer > ARENA_HOLDTIME)
                    {
                        ArenaStop();
                        return;
                    }
                }
                else
                    ArenaKeyTimer = 0;
                
                // Reset menu block
                if (Buttons == 0 && OldButtons == 0)
                    Player.MenuBlock = false;
            }
        }
コード例 #5
0
//-------------------------------- Update -------------------------------------
//
//  calls the update function of each entity
//-----------------------------------------------------------------------------
void Raven_Game::Update()
{ 
  //don't update if the user has paused the game
  if (m_bPaused) return;

  m_pGraveMarkers->Update();

  //get any player keyboard input
  GetPlayerInput();
  
  //update all the queued searches in the path manager
  m_pPathManager->UpdateSearches();

  //update any doors
  std::vector<Raven_Door*>::iterator curDoor =m_pMap->GetDoors().begin();
  for (curDoor; curDoor != m_pMap->GetDoors().end(); ++curDoor)
  {
    (*curDoor)->Update();
  }

  //update any current projectiles
  std::list<Raven_Projectile*>::iterator curW = m_Projectiles.begin();
  while (curW != m_Projectiles.end())
  {
    //test for any dead projectiles and remove them if necessary
    if (!(*curW)->isDead())
    {
      (*curW)->Update();

      ++curW;
    }
    else
    {    
      delete *curW;

      curW = m_Projectiles.erase(curW);
    }   
  }
  
  //update the bots
  bool bSpawnPossible = true;
  
  std::list<Raven_Bot*>::iterator curBot = m_Bots.begin();
  for (curBot; curBot != m_Bots.end(); ++curBot)
  {
    //if this bot's status is 'respawning' attempt to resurrect it from
    //an unoccupied spawn point
    if ((*curBot)->isSpawning() && bSpawnPossible)
    {
      bSpawnPossible = AttemptToAddBot(*curBot);
    }
    
    //if this bot's status is 'dead' add a grave at its current location 
    //then change its status to 'respawning'
    else if ((*curBot)->isDead())
    {
      //create a grave
      m_pGraveMarkers->AddGrave((*curBot)->Pos());

      //change its status to spawning
      (*curBot)->SetSpawning();
    }

    //if this bot is alive update it.
    else if ( (*curBot)->isAlive())
    {
      (*curBot)->Update();
    }  
  } 

  //update the triggers
  m_pMap->UpdateTriggerSystem(m_Bots);

  //if the user has requested that the number of bots be decreased, remove
  //one
  if (m_bRemoveABot)
  { 
    if (!m_Bots.empty())
    {
      Raven_Bot* pBot = m_Bots.back();
      if (pBot == m_pSelectedBot)m_pSelectedBot=0;
      NotifyAllBotsOfRemoval(pBot);
      delete m_Bots.back();
      m_Bots.remove(pBot);
      pBot = 0;
    }

    m_bRemoveABot = false;
  }
}
コード例 #6
0
script GRAPPLE_HOOK (int strength, int firetype)
{
    int playerInput;
    int myX; int myY; int myZ;

    int firerPln = ACS_ExecuteWithResult(GETFIRERPLN, 0,0,0);
    int projTid = PROJOFFSET+firerPln;

    while (ThingCount(0, projTid) > 0)
    {
        projTid++;
    }

    Thing_ChangeTID(0, projTid);

    SetActivatorToTarget(0);

    while (ThingCount(0, projTid) > 0)
    {
        myX = GetActorX(projTid);
        myY = GetActorY(projTid);
        myZ = GetActorZ(projTid);
        playerInput = GetPlayerInput(-1, MODINPUT_BUTTONS);

        switch (firetype)
        {
        case 0:
            if (!(GetPlayerInput(-1, MODINPUT_BUTTONS) & BT_ALTATTACK))
            {
                Thing_Remove(projTid);
                Spawn("GuaranteedTeleportFog", myX, myY, myZ-20.0);
                terminate;
            }
            break;

        case 1:
            if (!(GetPlayerInput(-1, MODINPUT_BUTTONS) & BT_ATTACK))
            {
                Thing_Remove(projTid);
                Spawn("GuaranteedTeleportFog", myX, myY, myZ-20.0);
                terminate;
            }
            break;

        case 2:
            if (CheckInventory("InventoryToggle"))
            {
                Thing_Remove(projTid);
                Spawn("GuaranteedTeleportFog", myX, myY, myZ-20.0);
                terminate;
            }
            break;
        }

        Delay(1);
    }

    Spawn("GrappleSpot", myX, myY, myZ, projTid);

    ACS_ExecuteAlways(GRAPPLE_REEL, 0, projTid, strength, firetype);
}