app.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * 2D Physic Engine
  3. * app.h:
  4. * Based on pikuma.com Learn Game Physics Engine Programming course.
  5. * Copyright (c) 2022 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 07/06/2022.
  8. */
  9. #ifndef PHYSICENGINE_APP_H
  10. #define PHYSICENGINE_APP_H
  11. #include <vector>
  12. #include <SDL.h>
  13. #include <timeprobe.h>
  14. #include <physics/particle.h>
  15. class application
  16. {
  17. private:
  18. uint32_t millisecsPreviousFrame;
  19. bool running;
  20. std::vector<particle *>particles;
  21. timeProbe waitTime, renderTime, updateTime;
  22. double deltaTime;
  23. vec2 pushForce = vec2(0, 0);
  24. vec2 mouseCursor;
  25. const double G = 0.00000000006674;
  26. bool leftButtonPressed;
  27. public:
  28. application() : running(false), leftButtonPressed(false) {};
  29. ~application() = default;
  30. void parseParameters(int argc, char *argv[]);
  31. bool isRunning() { return this->running; }
  32. void syncAndDeltatime();
  33. void setup();
  34. void input();
  35. void update();
  36. void render();
  37. void destroy();
  38. };
  39. #endif /* PHYSICENGINE_APP_H */