') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - Xapier14/MiniEngine: A wip cross-platform 2D Game Engine with ECS · GitHub
Skip to content

Latest commit

History

53 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

MiniEngine

A full-fledged cross-platform 2D Game Engine.

Setting up a MiniEngine project

  1. Install the metool command-line tool.
  2. Reference the Project/Assembly.
  3. Get an instance of the GameEngine.
    vargameEngine=GameContext.GetGameEngine();
  4. Create an initializer to load initial and additional game assets.
    vargameEngine=GameContext.GetGameEngine();gameEngine.AddInitializer(()=>{// do stuffreturnfalse;// return true if error occured in initializer.});
  5. Initialize the engine by calling gameEngine.Initialize() then start it by calling gameEngine.Run().
    vargameEngine=GameContext.GetGameEngine();gameEngine.AddInitializer(()=>{// do stuffreturnfalse;// return true if error occured in initializer.});gameEngine.Initialize()
    gameEngine.Run();
  6. Create a ./Assets/.indexfile in the root directory.
    This file will be used for defining asset folders that will be referenced by the game.
    Audio
    Sprites
    Scenes
    
    Will mark the folders ./Assets/Audio, ./Assets/Sprites, and ./Assets/Scenes as game assets.
  7. Run the metool pack command on the ./Assets directory.
    metool pack ./Assets
    This will produce a Assets.mea file that contains the assets specified by your .indexfile.
  8. Run dotnet run to run the project.

Basic Architecture

MiniEngine uses a simple ECS architecture.
Game objects are usually defined as an Entity that may contain one or many Component. Both of these objects/classes are ideally data-only. Behavior and logic are done by a System that act on its corresponding Component.

These Entities are then contained in a Scene.
Scenes are functionally equivalent to a game world or room.
You can switch scenes as needed for switching between levels or ui screens.

Using game assets

MiniEngine supports the use of a packed asset file that acts as a read-only virtual file system.

  1. Build and install the MiniEngine.Tools.CLI project and install as a dotnet tool.
  2. Create a .indexfile file in your project directory. Files and folders specified in this file are set to be packed by the CLI tool.
  3. Run metool pack on the project directory. The tool will produce a assets.mea file that contains your game assets.
  4. Place and include this file on your project's output directory.
  5. Reference a file by calling Resources.GetResource(string path). You may also opt for implicit conversion via strings when calling functions that uses MemoryResource.

Progress

Current State

Runnable with basic functionality included.

Roadmap

  • Create Basic Unit Structures
    • Size
    • Vector2
    • Color
  • Create BaseEngine Structure
    • Create engine init and cleanup
    • Create engine loop
  • Create Entity Component System
    • Create System Service (Register & Execute)
      • Support user-defined systems
    • Add wiring via reflection
    • Implement Basic Components and Systems
      • Add Transform and TransformSystem
      • Add Motion and MotionSystem
      • Add Sprite and DrawSystem
    • Implement Complex Components and Systems
      • Add PhysicsBehavior and PhysicsSystem
      • Add Script and ScriptSystem
      • Design a scripting API
  • Create Windowing System
    • Implement window creation and respect engine configuration
    • Add additional window configuration methods to be ran at runtime
  • Create Resource Manager
    • Create packed file format
      • Create index format
    • Create loader to load resources into memory
    • Create texture cache
    • Create font loader
  • Create Graphics Abstraction Layer
    • Add Primitive Draw Functions
      • Rectangle
      • Ellipse
      • Cicle
      • Pixel
      • Line
      • Curved Line
    • Add Sprite Draw Functions
      • Draw
      • Draw Spliced
  • Create Documentation
  • Create Example Projects
  • Publish to NuGet

About

A wip cross-platform 2D Game Engine with ECS

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages