refactor: added server project

This commit is contained in:
2025-06-06 23:54:03 +03:00
parent b835fb1582
commit 2294c06bf9
9 changed files with 142 additions and 66 deletions

View File

@@ -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();

View 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);
}

View 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>