Sin descripción
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.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 bugsMissed = 0;
  22. uint8_t linesOfCode = 5;
  23. uint16_t totalLines;
  24. std::vector<std::string> sourceCode;
  25. std::random_device rd;
  26. std::mt19937 generator;
  27. public:
  28. Debuggers()
  29. : generator(rd())
  30. {
  31. sAppName = "Debuggers";
  32. }
  33. public:
  34. bool OnUserCreate() override;
  35. bool OnUserUpdate(float fElapsedTime) override;
  36. bool OnUserDestroy() override;
  37. int GameScreenHeight() { return ScreenHeight() - linesOfCode * 10; };
  38. template <typename T>
  39. T GetRandom(T from = 0, T to = 1);
  40. private:
  41. void SpawnProgrammer();
  42. void SpawnBug();
  43. void SpawnBonus();
  44. Bug* CreateBug();
  45. Bonus* CreateBonus();
  46. bool GameOver();
  47. public:
  48. std::vector<Bug*> bugs;
  49. olc::ResourcePack pack;
  50. olc::Sprite playerSprite;
  51. olc::Sprite enemiesSprite;
  52. olc::Sprite bonusesSprite;
  53. olc::Sprite backgroundSprite;
  54. int playerFallSample;
  55. int bugFallSample;
  56. int bugCatchSample;
  57. const int gravity = 30;
  58. };
  59. }
  60. #endif