app.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /* debug */
  28. bool showVelocity = false;
  29. bool showForceSum = false;
  30. bool showAllForces = false;
  31. public:
  32. application() : running(false), leftButtonPressed(false) {};
  33. ~application() = default;
  34. void parseParameters(int argc, char *argv[]);
  35. bool isRunning() { return this->running; }
  36. void syncAndDeltatime();
  37. void setup();
  38. void input();
  39. void update();
  40. void render();
  41. void destroy();
  42. };
  43. #endif /* PHYSICENGINE_APP_H */