No Description
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 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef DEBUGGERS_H
  2. #define DEBUGGERS_H
  3. #include "olcPGEX_Sound.h"
  4. #include "olcPixelGameEngine.h"
  5. #include "bonus.h"
  6. #include "button.h"
  7. #include "bug.h"
  8. #include "player.h"
  9. #include "programmer.h"
  10. #include "game_state.h"
  11. #include <chrono>
  12. #include <list>
  13. #include <map>
  14. #include <random>
  15. #include <string>
  16. #include <vector>
  17. namespace pabloader {
  18. class Debuggers : public olc::PixelGameEngine {
  19. private:
  20. std::list<Programmer*> programmers;
  21. std::list<Bonus*> bonuses;
  22. std::list<Button*> buttons;
  23. std::list<BugParticle*> particles;
  24. std::map<BonusType, uint32_t> bonusesCatched;
  25. uint32_t bugsCatched = 0;
  26. uint32_t bugsCatchedByPlayer = 0;
  27. uint32_t bugsMissed = 0;
  28. uint8_t linesOfCode = 5;
  29. uint16_t totalLines;
  30. std::list<std::string> originalSourceCode;
  31. std::list<std::string> sourceCode;
  32. GameState state = STATE_MAIN_MENU;
  33. GameState prevState;
  34. float helpRotation = 0;
  35. std::mt19937 generator;
  36. public:
  37. Debuggers()
  38. : generator(std::chrono::system_clock::now().time_since_epoch().count())
  39. {
  40. sAppName = "Debuggers";
  41. }
  42. public:
  43. bool OnUserCreate() override;
  44. bool OnUserUpdate(float fElapsedTime) override;
  45. bool OnUserDestroy() override;
  46. int GameScreenHeight() { return ScreenHeight() - linesOfCode * 10; }
  47. GameState GetState() { return state; }
  48. void SwitchState(GameState newState);
  49. template <typename T>
  50. T GetRandom(T from = 0, T to = 1);
  51. private:
  52. void ResetGame();
  53. void ClearButtons();
  54. void DrawMenu();
  55. void DrawSourceCode();
  56. void DrawLogo();
  57. void SpawnPlayer();
  58. void SpawnProgrammer();
  59. void SpawnBug();
  60. void SpawnBugParticles(Bug* bug);
  61. void SpawnBonus();
  62. Bug* CreateBug();
  63. BugParticle* CreateBugParticle();
  64. Bonus* CreateBonus();
  65. private: // Gamemodes
  66. bool MainMenu(float dt);
  67. bool GamePlay(float dt);
  68. bool PauseMenu(float dt);
  69. bool GameOver(float dt);
  70. bool HelpMenu(float dt);
  71. public:
  72. std::list<Bug*> bugs;
  73. olc::ResourcePack pack;
  74. olc::Sprite playerSprite;
  75. olc::Sprite enemiesSprite;
  76. olc::Sprite bonusesSprite;
  77. olc::Sprite backgroundSprite;
  78. int bgMusic;
  79. int playerFallSample;
  80. int bugFallSample;
  81. int bugCatchSample;
  82. int hoverSample;
  83. int clickSample;
  84. int bonusSample;
  85. const int gravity = 20;
  86. #ifdef _DEBUG
  87. bool debug = false;
  88. #endif
  89. };
  90. }
  91. #endif