-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (34 loc) · 1.08 KB
/
Program.cs
File metadata and controls
41 lines (34 loc) · 1.08 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
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using GameServer;
namespace GameServer
{
class Program
{
private static bool isRunning = false;
private static void Main(string[] args)
{
Console.Title = "Shooter Game Server";
isRunning = true;
Thread mainThread = new Thread(new ThreadStart(MainThread));
mainThread.Start();
Server.Start(50, 25569);
}
private static void MainThread() {
Console.WriteLine($"Main thread started. Running at {Constants.TICKS_PER_SEC} ticks per second");
DateTime _nextLoop = DateTime.Now;
while(isRunning) {
while(_nextLoop < DateTime.Now) {
GameLogic.Update();
_nextLoop = _nextLoop.AddMilliseconds(Constants.MS_PER_TICK);
if(_nextLoop > DateTime.Now) {
Thread.Sleep(_nextLoop - DateTime.Now);
}
}
}
}
}
}