-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (26 loc) · 709 Bytes
/
Copy pathmain.cpp
File metadata and controls
31 lines (26 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "Ball.hpp"
#include "Renderer.hpp"
#include "PhysicsEngine.hpp"
#include <thread>
#include <vector>
int main() {
Renderer renderer(800, 600, "Bouncing Ball Simulator");
if (!renderer.init()) return -1;
std::vector<Ball> balls;
balls.emplace_back(400.0f, 100.0f);
PhysicsEngine physics(balls, 800, 600);
std::thread physicsThread([&]() {
physics.run(); // Separate thread updates physics
});
while (!renderer.shouldClose()) {
renderer.beginFrame();
for (auto& ball : balls) {
renderer.draw(ball);
}
renderer.endFrame();
}
physics.stop();
physicsThread.join();
renderer.cleanup();
return 0;
}