Skip to content

A comprehensive, modular game engine built entirely in C# targeting .NET 8.0. Features include component-based architecture, scene management, 3D rendering, physics simulation, audio system, input handling, UI framework, and networking. Cross-platform support for Windows, macOS, and Linux. Perfect for 2D/3D game development.

Notifications You must be signed in to change notification settings

Luka12-dev/Xengine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

348 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xengine

Xengine Logo

Gameplay Demo

Xengine - A Modern C# Game Engine

Xengine is a comprehensive, modular game engine written entirely in C# targeting .NET 8.0. It provides a complete foundation for building 2D and 3D games with a component-based architecture.

Features

Core Systems

  • Application Management - Configuration, lifecycle management, and platform abstraction
  • Time System - Delta time, fixed timestep, time scaling, and timer utilities
  • Event System - Attribute-based and delegate-based event handling
  • Logging - Multi-target logging with log levels and file output
  • Thread Safety - Main thread dispatching and object pooling

Math Library

  • Vector Types - Vector2, Vector3, Vector4 with full operator support
  • Quaternion - Rotation representation with Euler angle conversion
  • Matrix4x4 - Transform matrices, projections, and view matrices
  • Transform - Position, rotation, scale with parent-child relationships
  • Geometry - Ray, Plane, Sphere, BBox, Rect for spatial calculations
  • Color - RGB/HSV color representation and manipulation
  • Random - Game-friendly random number generation

Scene System

  • Scene Graph - Hierarchical game object management
  • GameObject - Entity container with transform and component system
  • Component - Modular behavior system with lifecycle callbacks
  • GameTransform - Local and world space transformations

Rendering

  • Camera - Perspective and orthographic projection
  • Mesh Renderer - Basic mesh rendering support
  • Materials - Color, texture, and PBR properties
  • Lighting - Directional, point, and spot lights

Physics

  • Rigid Bodies - Mass, velocity, forces, and collision response
  • Colliders - Box, sphere, capsule, and mesh colliders
  • Raycasting - Ray intersection queries
  • Trigger System - Non-physical collision detection

Audio

  • Audio System - Sound playback management
  • Audio Source - 3D positional audio
  • Audio Clips - Sound data loading and caching
  • Audio Mixer - Volume groups and effects

Input

  • Keyboard - Key states, press, and release detection
  • Mouse - Position, buttons, scroll wheel
  • Input Actions - Rebindable input abstraction

UI System

  • Canvas - Screen-space UI rendering
  • Elements - Panel, Text, Button, Image, InputField, Slider, Toggle
  • Layout - Anchoring and pivot-based positioning

Resources

  • Resource Manager - Asset loading and caching
  • File System - Virtual file system with mount points
  • Resource Types - Text, binary, JSON, prefabs

Networking

  • Server/Client - TCP-based networking
  • Message System - Serialized network messages
  • Connection Management - Client tracking and events

Project Structure

Xengine/
├── Source/
│   ├── Xengine.Core/          # Core utilities and application
│   ├── Xengine.Math/          # Mathematical types and functions
│   ├── Xengine.Events/        # Event system
│   ├── Xengine.FileSystem/    # Virtual file system
│   ├── Xengine.Scene/         # Scene graph and components
│   ├── Xengine.Rendering/     # Rendering system
│   ├── Xengine.Physics/       # Physics simulation
│   ├── Xengine.Audio/         # Audio system
│   ├── Xengine.Input/         # Input handling
│   ├── Xengine.UI/            # User interface
│   ├── Xengine.Resources/     # Asset management
│   ├── Xengine.Network/       # Networking
│   ├── Xengine.Engine/        # Main engine coordinator
│   ├── Xengine.Launcher/      # Application entry point
│   └── Xengine.Sample/        # Sample game code
└── Xengine.sln                # Visual Studio solution

Requirements

  • .NET 8.0 SDK
  • Windows, macOS, or Linux

Building

Using PowerShell (Windows)

.\run.ps1

Using .NET CLI

cd Xengine
dotnet build
dotnet run --project Source/Xengine.Launcher

Build Configuration

# Debug build
dotnet build -c Debug

# Release build
dotnet build -c Release

Quick Start

Creating a Basic Game

using Xengine.Core;
using Xengine.Engine;
using Xengine.Scene;
using Xengine.Math;

// Configure and create engine
var config = new ApplicationConfig
{
    Name = "My Game",
    WindowWidth = 1280,
    WindowHeight = 720
};

using var engine = new Engine(config);
engine.Initialize();

// Create a scene
var scene = engine.LoadScene("MainScene");

// Create a camera
var cameraObj = scene.CreateGameObject("Camera", new Vector3(0, 5, -10));
var camera = cameraObj.AddComponent<CameraComponent>();
cameraObj.Transform.LookAt(Vector3.Zero);

// Create a game object with custom component
var player = scene.CreateGameObject("Player");
player.AddComponent<PlayerController>();

// Run the game
engine.Run();

Creating Custom Components

public class PlayerController : Component
{
    public float Speed = 5f;
    
    protected override void OnUpdate()
    {
        var input = InputSystem.Instance;
        var move = Vector3.Zero;
        
        if (input.IsKeyDown(KeyCode.W)) move.Z += 1;
        if (input.IsKeyDown(KeyCode.S)) move.Z -= 1;
        if (input.IsKeyDown(KeyCode.A)) move.X -= 1;
        if (input.IsKeyDown(KeyCode.D)) move.X += 1;
        
        Transform.Position += move.Normalized * Speed * Time.Delta;
    }
}

Command Line Arguments

Argument Description
-headless Run without graphics window
-editor Enable editor mode
-width <n> Set window width
-height <n> Set window height
-fullscreen Start in fullscreen mode

Architecture

Xengine follows a modular, layered architecture:

  1. Core Layer - Basic utilities, logging, time management
  2. Math Layer - Mathematical types independent of engine
  3. Systems Layer - Independent subsystems (physics, audio, input)
  4. Scene Layer - Game object and component management
  5. Engine Layer - Coordination of all systems
  6. Application Layer - Game-specific code

License

This project is provided as-is for educational and development purposes.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

About

A comprehensive, modular game engine built entirely in C# targeting .NET 8.0. Features include component-based architecture, scene management, 3D rendering, physics simulation, audio system, input handling, UI framework, and networking. Cross-platform support for Windows, macOS, and Linux. Perfect for 2D/3D game development.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors