refactor: added server project
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Integration.MonoGame;
|
||||
|
||||
using var game = new Pong.GamePong();
|
||||
bool isServerEnabled = Environment.GetCommandLineArgs().FirstOrDefault(x => x.CompareTo("--server") == 0) is not null;
|
||||
|
||||
game.Universe
|
||||
.InstantiateUniverseObject().SetUniverseObject("Desktop HO")
|
||||
IUniverse universe = Pong.PongUniverse.GetPongUniverse(isServerEnabled, isClientEnabled: true);
|
||||
|
||||
universe.InstantiateUniverseObject().SetUniverseObject("Desktop HO")
|
||||
.BehaviourController.AddBehaviour<KeyboardInputsBehaviour>();
|
||||
|
||||
game.Graphics.PreferredBackBufferWidth = 1024;
|
||||
game.Graphics.PreferredBackBufferHeight = 576;
|
||||
game.Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
||||
using MonoGameWindow monoGameWindow = new(universe);
|
||||
|
||||
game.Run();
|
||||
monoGameWindow.Graphics.PreferredBackBufferWidth = 1024;
|
||||
monoGameWindow.Graphics.PreferredBackBufferHeight = 576;
|
||||
monoGameWindow.Graphics.GraphicsProfile = GraphicsProfile.HiDef;
|
||||
|
||||
monoGameWindow.Run();
|
||||
|
22
Platforms/Server/Program.cs
Normal file
22
Platforms/Server/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
IUniverse universe = Pong.PongUniverse.GetPongUniverse(isServerEnabled: true, isClientEnabled: false);
|
||||
|
||||
DateTime lastRun = DateTime.UtcNow;
|
||||
TimeSpan interval = new(0, 0, 0, 0, 16);
|
||||
TimeSpan timeSinceStart = new(0);
|
||||
|
||||
universe.Initialize();
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (lastRun + interval <= DateTime.UtcNow)
|
||||
{
|
||||
lastRun += interval;
|
||||
timeSinceStart += interval;
|
||||
universe.Update(new(timeSinceStart, interval));
|
||||
}
|
||||
Thread.Sleep(1);
|
||||
}
|
20
Platforms/Server/Server.csproj
Normal file
20
Platforms/Server/Server.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../Shared/Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105">
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user