-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
67 lines (62 loc) · 1.97 KB
/
Program.cs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.IO;
namespace Spacerunner3
{
class Program
{
public static void Reset(Scene scene)
{
var step = 1.2;
Console.WriteLine(step);
Console.WriteLine(Math.Log(step, 2));
Console.WriteLine(Math.Round(Math.Log(step, 2)));
Console.WriteLine(Math.Pow(2, Math.Round(Math.Log(step, 2))));
scene.Spawn(new SceneClearer());
scene.Update(0);
if (scene.Objects.Count != 0)
{
throw new System.Exception("Reset failed, objects remaining: " + string.Join(", ", scene.Objects));
}
scene.Camera.ResetOriginShift();
scene.Spawn(new PhysicsManager());
scene.Spawn(new AsteroidManager());
scene.Spawn(new DistanceTracker(scene.Camera));
scene.Spawn(new Player());
scene.Update(0);
}
private static void InitSettings(string? filename)
{
if (filename == null)
{
filename = "settings.cfg";
}
Settings.Grab = File.Exists(filename) ? Settings.Load(filename) : new Settings();
}
private static void SaveSettings(string? filename)
{
if (filename == null)
{
filename = "settings.cfg";
}
if (!File.Exists(filename))
{
Settings.Grab.Save(filename);
}
}
static void Main(string?[] args)
{
var arg = args.Length == 0 ? null : args[0];
if (arg != null && arg.EndsWith(".srv3") == true)
{
new MovieWindow(arg).Run();
return;
}
InitSettings(arg);
var scene = new Scene(Settings.Grab.ScreenSize);
Reset(scene);
var display = new DisplayWindow(scene);
display.Run();
SaveSettings(arg);
}
}
}