app.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/body.h>
  15. class application
  16. {
  17. private:
  18. uint32_t millisecsPreviousFrame;
  19. bool running;
  20. std::vector<body *>bodies;
  21. timeProbe waitTime, renderTime, updateTime;
  22. double deltaTime;
  23. vec2 pushForce = vec2(0, 0);
  24. vec2 mouseCursor;
  25. vec2 anchor;
  26. double k = 100;
  27. double restLenght = 400;
  28. const double G = 0.00000000006674;
  29. bool leftButtonPressed;
  30. /* debug */
  31. bool showVelocity = false;
  32. bool showForceSum = false;
  33. bool showAllForces = false;
  34. public:
  35. application() : running(false), leftButtonPressed(false) {};
  36. ~application() = default;
  37. void parseParameters(int argc, char *argv[]);
  38. bool isRunning() { return this->running; }
  39. void syncAndDeltatime();
  40. void setup();
  41. void input();
  42. void update();
  43. void render();
  44. void destroy();
  45. };
  46. #endif /* PHYSICENGINE_APP_H */