Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

debuggers.h 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef DEBUGGERS_H
  2. #define DEBUGGERS_H
  3. #include "olcPGEX_Sound.h"
  4. #include "olcPixelGameEngine.h"
  5. #include "bonus.h"
  6. #include "bug.h"
  7. #include "player.h"
  8. #include "programmer.h"
  9. #include <chrono>
  10. #include <map>
  11. #include <random>
  12. #include <string>
  13. #include <vector>
  14. namespace pabloader {
  15. class Debuggers : public olc::PixelGameEngine {
  16. private:
  17. std::vector<Programmer*> programmers;
  18. std::vector<Bonus*> bonuses;
  19. std::map<BonusType, uint32_t> bonusesCatched;
  20. uint32_t bugsCatched = 0;
  21. uint32_t bugsCatchedByPlayer = 0;
  22. uint32_t bugsMissed = 0;
  23. uint8_t linesOfCode = 5;
  24. uint16_t totalLines;
  25. std::vector<std::string> sourceCode;
  26. std::random_device rd;
  27. std::mt19937 generator;
  28. public:
  29. Debuggers()
  30. : generator(rd())
  31. {
  32. sAppName = "Debuggers";
  33. }
  34. public:
  35. bool OnUserCreate() override;
  36. bool OnUserUpdate(float fElapsedTime) override;
  37. bool OnUserDestroy() override;
  38. int GameScreenHeight() { return ScreenHeight() - linesOfCode * 10; };
  39. template <typename T>
  40. T GetRandom(T from = 0, T to = 1);
  41. private:
  42. void SpawnProgrammer();
  43. void SpawnBug();
  44. void SpawnBonus();
  45. Bug* CreateBug();
  46. Bonus* CreateBonus();
  47. bool GameOver();
  48. public:
  49. std::vector<Bug*> bugs;
  50. olc::ResourcePack pack;
  51. olc::Sprite playerSprite;
  52. olc::Sprite enemiesSprite;
  53. olc::Sprite bonusesSprite;
  54. olc::Sprite backgroundSprite;
  55. int playerFallSample;
  56. int bugFallSample;
  57. int bugCatchSample;
  58. const int gravity = 30;
  59. #ifdef _DEBUG
  60. bool debug = true;
  61. #endif
  62. };
  63. }
  64. #endif