-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (43 loc) · 1.32 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (43 loc) · 1.32 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <chrono>
#include <thread>
class Vector3 {
public:
float x, y, z;
Vector3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
Vector3 operator*(float scalar) const {
return Vector3(x * scalar, y * scalar, z * scalar);
}
};
class Transform {
public:
void Rotate(const Vector3& rotation) {
// This is a placeholder for rotation logic.
// In a real application, you would update the object's rotation state here.
std::cout << "Rotating by (" << rotation.x << ", " << rotation.y << ", " << rotation.z << ") degrees\n";
}
};
class DayNightCycle {
public:
float rotation = 15.0f; // Rotates 15° per second (1 day = 24 seconds)
Transform transform;
void Start() {
// Initialization code if needed
}
void Update(float deltaTime) {
transform.Rotate(Vector3(rotation, 0, 0) * deltaTime);
}
};
int main() {
DayNightCycle cycle;
cycle.Start();
auto previous = std::chrono::steady_clock::now();
while (true) {
auto current = std::chrono::steady_clock::now();
std::chrono::duration<float> elapsed = current - previous;
previous = current;
cycle.Update(elapsed.count());
std::this_thread::sleep_for(std::chrono::milliseconds(16)); // Approximate 60 FPS
}
return 0;
}