-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (35 loc) · 1.07 KB
/
Program.cs
File metadata and controls
45 lines (35 loc) · 1.07 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
using Orbit;
using Gtk;
using System.Diagnostics;
static void StartApplication() {
Application.Init();
new App();
Application.Run();
}
static void StartPhysics() {
PhysicsRunner fr = new();
fr.LoadPreset("solar system");
Stopwatch time = Stopwatch.StartNew();
double wantedDelta, timeTook = 0;
while(Shared.Running) {
wantedDelta = (1000 * (Shared.deltaTime / Shared.multiplier));
lock(Shared.DataLock) {
fr.ProcessDataChanges();
while(timeTook > wantedDelta) {
fr.Update(Shared.deltaTime);
timeTook -= wantedDelta;
}
}
Thread.Sleep(5);
if(!Shared.Paused) {
timeTook += time.ElapsedMilliseconds;
//Stop the program from completely hanging if too far behind
//while also giving the user noticable slowdown to notify
if(timeTook > 250) { timeTook = 100; }
}
time.Restart();
}
}
Thread thr1 = new Thread(StartPhysics);
thr1.Start();
StartApplication();