Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. void Lab06_Gravity_Collisions::GameTick(double deltaTime)
  2. {
  3.     //double actorSpeed;
  4.     if(GAME_ENGINE->IsKeyDown('A') != true || GAME_ENGINE->IsKeyDown('D') != true)
  5.     {
  6.         m_ActorSpeed = 0;
  7.     }
  8.     if(GAME_ENGINE->IsKeyDown('D'))
  9.     {
  10.         m_ActorSpeed += 150.0;
  11.     }
  12.     if(GAME_ENGINE->IsKeyDown('A'))
  13.     {
  14.         m_ActorSpeed += -150.0;
  15.     }
  16.     if(GAME_ENGINE->IsKeyDown(VK_HOME))
  17.     {
  18.         m_ActorPos.x = 0;
  19.         m_ActorPos.y = 0;
  20.  
  21.         m_ActorVelocity.x = m_ActorSpeed;
  22.         m_ActorVelocity.y = 0;
  23.     }
  24.  
  25.    
  26.  
  27.  
  28.     m_ActorVelocity.x = m_ActorSpeed;
  29.     m_ActorPos.x += m_ActorVelocity.x * deltaTime;
  30.    
  31.  
  32.  
  33.     m_ActorPos = m_ActorPos + m_ActorVelocity * deltaTime ;
  34.    
  35.    
  36.  
  37.     if(m_ActorPos.y > 330)
  38.     {
  39.         m_ActorPos.y = 330;
  40.         m_ActorVelocity.y = 0;
  41.         m_ActorVelocity.x = 0;
  42.         m_ActorVelocity = m_ActorVelocity + m_Gravity * deltaTime;
  43.     }
  44.     else
  45.     {
  46.         m_ActorVelocity = m_ActorVelocity + m_Gravity * deltaTime;
  47.     }
  48.  
  49.     m_HitActorVPtr->SetPos(m_ActorPos.x + 15, m_ActorPos.y);
  50.     m_HitActorHPtr->SetPos(m_ActorPos.x, m_ActorPos.y);
Add Comment
Please, Sign In to add comment