Player.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. /******************************************************************************/
  4. /******************************************************************************/
  5. bool Player::update()
  6. {
  7. if(action) // if performing automatic action
  8. {
  9. if(Kb.b(Kb.qwerty(KB_W)) || Kb.b(Kb.qwerty(KB_S)) || Kb.b(Kb.qwerty(KB_A)) || Kb.b(Kb.qwerty(KB_D)) || Kb.b(KB_SPACE) || Kb.b(KB_LSHIFT) || DPad.axis.any() || DPadY.dir || Rot.delta.any()) // if any command key is pressed
  10. {
  11. actionBreak(); // break action
  12. }
  13. }
  14. if(!action) // modify input only when there is no automatic action
  15. {
  16. // turn & move
  17. input.turn.x=Kb.b(Kb.qwerty(KB_Q))-Kb.b(Kb.qwerty(KB_E));
  18. input.turn.y=Kb.b(Kb.qwerty(KB_T))-Kb.b(Kb.qwerty(KB_G));
  19. input.move.x=Kb.b(Kb.qwerty(KB_D))-Kb.b(Kb.qwerty(KB_A))+DPad.axis.x;
  20. input.move.z=Kb.b(Kb.qwerty(KB_W))-Kb.b(Kb.qwerty(KB_S))+DPad.axis.y;
  21. input.move.y=Kb.b( KB_SPACE)-Kb.b( KB_LSHIFT)+DPadY.dir;
  22. // dodge, crouch, walk, jump
  23. input.dodge = Kb.bd(Kb.qwerty(KB_D))-Kb.bd(Kb.qwerty(KB_A));
  24. input.crouch=((Kb.b (KB_LSHIFT) || DPadY.dir==-1) && !ctrl.flying());
  25. input.walk = Kb.b (KB_LCTRL );
  26. input.jump =((Kb.bp(KB_SPACE ) || DPadY.dir==+1) ? 3.5f : 0);
  27. // change flying
  28. if(Kb.bp(Kb.qwerty(KB_F)))ctrl.flying(!ctrl.flying());
  29. // adjust turn speed
  30. turn_speed=((ctrl.flying() && !input.walk && input.move.z==1) ? 1 : 3.5f);
  31. // mouse turn
  32. if(ViewMode!=VIEW_ISO)
  33. {
  34. flt max =DegToRad(900)*Time.d(),
  35. dx =Ms.d().x*1.5f,
  36. dy =Ms.d().y*1.5f;
  37. angle.x-=Mid(dx, -max, max);
  38. angle.y+=Mid(dy, -max, max);
  39. }
  40. angle.x-=Rot.delta.x*1.5f;
  41. angle.y+=Rot.delta.y*1.5f;
  42. }
  43. return ::EE::Game::Chr::update();
  44. }
  45. /******************************************************************************/