SHARE
TWEET

Untitled

a guest Jun 17th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (keyboard->IsKeyPressed('P'))
  2. {
  3.     if (player_->shield == true)
  4.         player_->shield = false;
  5.     else
  6.         player_->shield = true;
  7. }
  8.  
  9. if (player_->shield && player_->shieldPower > 0)
  10. {
  11.     if (keyboard->IsKeyPressed(VK_SPACE))
  12.     {
  13.         XMVECTOR playerForward = player_->GetForwardVector();
  14.         XMVECTOR bulletPosition = player_->GetPosition() + playerForward * 10.0f;
  15.         SpawnBullet(bulletPosition, playerForward);
  16.     }
  17.  
  18.     player_->shieldActive = true;
  19.     if (GetTickCount() - player_->time > 100)
  20.     {
  21.         player_->time = GetTickCount();
  22.         player_->shieldPower--;
  23.         if (player_->shieldPower <= 40)
  24.         {
  25.             player_->shieldPowerLow = true;
  26.         }
  27.         else
  28.         {
  29.             player_->shieldPowerLow = false;
  30.         }
  31.     }
  32. }
  33. else
  34.     player_->shieldActive = false;
  35.      
  36. void PlayingState::OnRender(System *system)
  37. {
  38. Graphics *graphics = system->GetGraphics();
  39. FontEngine *fontEngine = graphics->GetFontEngine();
  40. Player *player = new Player();
  41.  
  42. Game *game = system->GetGame();
  43. game->RenderEverything(system->GetGraphics());
  44.  
  45. std::stringstream buffer;
  46. buffer << player->shieldPower;
  47.  
  48. fontEngine->DrawText(buffer.str().c_str(), 50, 100, 0xffffffff,
  49. FontEngine::FONT_TYPE_SMALL);
  50. }
  51.      
  52. class Player
  53. {
  54. public:
  55.  
  56. int shootDelay;
  57. int time;
  58. int shieldPower;
  59. bool shield;
  60. bool shieldActive;
  61. bool fullShield;
  62. bool shieldPowerLow;
  63. bool shoot;
  64. }
  65.      
  66. Player::Player() :
  67. shootDelay(500),
  68. shieldPower(100),
  69. fullShield(true),
  70. shieldPowerLow(false),
  71. shield(false),
  72. shieldActive(false),
  73. shoot(false)
  74. {
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top