From d2621e2aec463c92d5471f5fa9000e9bbc341709 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Sun, 12 Apr 2026 21:37:53 +0200 Subject: [PATCH] init c# backend --- backend/.gitignore | 50 ++++++++++++++++++++++++++ backend/Backend.csproj | 16 +++++++++ backend/Program.cs | 12 +++++++ backend/README.md | 82 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 backend/.gitignore create mode 100644 backend/Backend.csproj create mode 100644 backend/Program.cs create mode 100644 backend/README.md diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..43ccafb --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,50 @@ +# Build results +bin/ +obj/ +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ + +# Visual Studio +.vs/ +.vscode/ +*.sln.iml +*.sln.docstates +*.user +*.userprefs +*.userosscache +*.sln.user + +# ReSharper +.idea/ +*.resharper +*.resharper.user +*.DotSettings.user +_ReSharper*/ +*.[Rr]e[Ss]harper +*.sln.iml + +# Local environment +.env +.env.local +appsettings.Development.json + +# NuGet +.nuget/ +*.nupkg +*.snupkg +packages/ + +# Rider +.idea/ +*.sln.iml +*.log + +# macOS +.DS_Store diff --git a/backend/Backend.csproj b/backend/Backend.csproj new file mode 100644 index 0000000..748c613 --- /dev/null +++ b/backend/Backend.csproj @@ -0,0 +1,16 @@ + + + + Exe + net10.0 + latest + enable + Love2DBackend + Backend + + + + + + + diff --git a/backend/Program.cs b/backend/Program.cs new file mode 100644 index 0000000..d9f4eb9 --- /dev/null +++ b/backend/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace Love2DBackend +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello from LÖVE2D Backend!"); + } + } +} diff --git a/backend/README.md b/backend/README.md new file mode 100644 index 0000000..3bedb6f --- /dev/null +++ b/backend/README.md @@ -0,0 +1,82 @@ +# ENET Gaming Backend + +A multiplayer game server written in C# using ENet for networking. +Designed to support mutiple of my LÖVE2D game experiments at once. + +## Architecture + +``` +┌─────────────────────────────────────────────────────────────┐ +│ LÖVE2D Game Clients │ +│ (Fennel/Lua with Love2D Framework) │ +└────────────────────────────────┬────────────────────────────┘ + │ (UDP via ENet) + │ + ┌────────────┴────────────┐ + │ ENet-CSharp Server │ + │ (Multiplayer Backend) │ + └────────────┬────────────┘ + │ + ┌────────────┴────────────┐ + │ Game State Manager │ + │ Session Storage │ + │ Player Coordination │ + └────────────────────────┘ +``` + +## Technology Stack + +- **Language**: C# (.NET) +- **Networking**: [ENet-CSharp](https://github.com/nxrighthere/ENet-CSharp) - reliable UDP multiplayer protocol +- **Deployment**: Docker + Nomad +- **Port**: `7777` (UDP, configurable) + +## Quick Start + +### Prerequisites + +- .NET 8.0 or later +- ENet-CSharp (vendored or via NuGet) +- Docker (for containerization) + +### Local Development + +```bash +cd backend +dotnet build +dotnet run +``` + +The server will start and listen on `127.0.0.1:7777` by default. + +### Testing Connection + +With a LÖVE2D client configured to connect to `localhost:7777`: + +```bash +love ../two_player_cleaning_game +``` + +## Configuration + +Server behavior is controlled via environment variables: + +```bash +ENET_HOST=0.0.0.0 # Bind address +ENET_PORT=7777 # UDP port +``` + +## Resources + +- [Learn X In Y C#](https://learnxinyminutes.com/csharp/) + +## Next Steps + +- [ ] Set up C# project structure +- [ ] Integrate ENet-CSharp dependency +- [ ] Implement basic server startup +- [ ] Define message protocol +- [ ] Create player session management +- [ ] Build Docker image +- [ ] Test Nomad deployment +- [ ] Implement game state synchronization