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 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 <list>
  11. #include <map>
  12. #include <random>
  13. #include <string>
  14. #include <vector>
  15. namespace pabloader {
  16. enum GameState {
  17. STATE_MAIN_MENU,
  18. STATE_GAME,
  19. STATE_PAUSE_MENU,
  20. STATE_GAME_OVER,
  21. STATE_HELP,
  22. STATE_QUIT
  23. };
  24. class Debuggers : public olc::PixelGameEngine {
  25. private:
  26. std::list<Programmer*> programmers;
  27. std::list<Bonus*> bonuses;
  28. std::map<BonusType, uint32_t> bonusesCatched;
  29. uint32_t bugsCatched = 0;
  30. uint32_t bugsCatchedByPlayer = 0;
  31. uint32_t bugsMissed = 0;
  32. uint8_t linesOfCode = 5;
  33. uint16_t totalLines;
  34. std::list<std::string> originalSourceCode;
  35. std::list<std::string> sourceCode;
  36. GameState state = STATE_MAIN_MENU;
  37. std::mt19937 generator;
  38. public:
  39. Debuggers()
  40. : generator(std::chrono::system_clock::now().time_since_epoch().count())
  41. {
  42. sAppName = "Debuggers";
  43. }
  44. public:
  45. bool OnUserCreate() override;
  46. bool OnUserUpdate(float fElapsedTime) override;
  47. bool OnUserDestroy() override;
  48. int GameScreenHeight() { return ScreenHeight() - linesOfCode * 10; }
  49. GameState GetState() { return state; }
  50. template <typename T>
  51. T GetRandom(T from = 0, T to = 1);
  52. private:
  53. void ResetGame();
  54. void SwitchState(GameState newState);
  55. void DrawMenu();
  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 playerFallSample;
  76. int bugFallSample;
  77. int bugCatchSample;
  78. const int gravity = 25;
  79. #ifdef _DEBUG
  80. bool debug = false;
  81. #endif
  82. };
  83. }
  84. #endif