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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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::map<BonusType, uint32_t> bonusesCatched;
  24. uint32_t bugsCatched = 0;
  25. uint32_t bugsCatchedByPlayer = 0;
  26. uint32_t bugsMissed = 0;
  27. uint8_t linesOfCode = 5;
  28. uint16_t totalLines;
  29. std::list<std::string> originalSourceCode;
  30. std::list<std::string> sourceCode;
  31. GameState state = STATE_MAIN_MENU;
  32. GameState prevState;
  33. float helpRotation = 0;
  34. std::mt19937 generator;
  35. public:
  36. Debuggers()
  37. : generator(std::chrono::system_clock::now().time_since_epoch().count())
  38. {
  39. sAppName = "Debuggers";
  40. }
  41. public:
  42. bool OnUserCreate() override;
  43. bool OnUserUpdate(float fElapsedTime) override;
  44. bool OnUserDestroy() override;
  45. int GameScreenHeight() { return ScreenHeight() - linesOfCode * 10; }
  46. GameState GetState() { return state; }
  47. void SwitchState(GameState newState);
  48. template <typename T>
  49. T GetRandom(T from = 0, T to = 1);
  50. private:
  51. void ResetGame();
  52. void ClearButtons();
  53. void DrawMenu();
  54. void DrawSourceCode();
  55. void DrawLogo();
  56. void SpawnPlayer();
  57. void SpawnProgrammer();
  58. void SpawnBug();
  59. void SpawnBonus();
  60. Bug* CreateBug();
  61. Bonus* CreateBonus();
  62. private: // Gamemodes
  63. bool MainMenu(float dt);
  64. bool GamePlay(float dt);
  65. bool PauseMenu(float dt);
  66. bool GameOver(float dt);
  67. bool HelpMenu(float dt);
  68. public:
  69. std::list<Bug*> bugs;
  70. olc::ResourcePack pack;
  71. olc::Sprite playerSprite;
  72. olc::Sprite enemiesSprite;
  73. olc::Sprite bonusesSprite;
  74. olc::Sprite backgroundSprite;
  75. int bgMusic;
  76. int playerFallSample;
  77. int bugFallSample;
  78. int bugCatchSample;
  79. int hoverSample;
  80. int clickSample;
  81. const int gravity = 25;
  82. #ifdef _DEBUG
  83. bool debug = false;
  84. #endif
  85. };
  86. }
  87. #endif