MonoGameLibrary 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MonoGameLibrary --version 1.0.1
                    
NuGet\Install-Package MonoGameLibrary -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MonoGameLibrary" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MonoGameLibrary" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MonoGameLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MonoGameLibrary --version 1.0.1
                    
#r "nuget: MonoGameLibrary, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MonoGameLibrary@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MonoGameLibrary&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MonoGameLibrary&version=1.0.1
                    
Install as a Cake Tool

MonoGame Library

A comprehensive utility library for MonoGame that provides higher-level abstractions and tools for common game development tasks. This library simplifies MonoGame development by offering a structured approach to graphics, input, audio, scene management, and AI systems.

Overview

MonoGame Library is built around a singleton Core pattern that provides centralized access to all game systems. It extends MonoGame's Game class to offer a more organized and feature-rich development experience while maintaining the flexibility and performance of the underlying framework.

Key Benefits

  • Simplified Game Structure: Organized subsystems with consistent APIs
  • Automatic Resource Management: Scene-based content loading with automatic cleanup
  • Enhanced Input Handling: Edge detection and multi-device support
  • Flexible Asset Loading: XML and JSON configuration for sprites and animations
  • Extensible Architecture: Interface-based design for easy customization

Architecture

The library follows a Core Singleton Pattern where all subsystems are accessible through static properties:

Core.Graphics     // Graphics device and rendering
Core.Input        // Keyboard, mouse, and gamepad input
Core.Audio        // Sound effects and music
Core.SpriteBatch  // Shared sprite batch for rendering
Core.Content      // Global content manager

Namespace Documentation

Explore detailed documentation for each namespace:

🎨 Graphics

Comprehensive 2D graphics system with sprites, animations, texture atlases, and tile-based rendering.

  • Classes: TextureAtlas, Sprite, AnimatedSprite, CharacterSprite, PlayerSprite, NPCSprite, Tilemap, Tileset
  • Features: XML/JSON configuration, animation state management, directional sprites, tile graphics

🎮 Input

Unified input management with edge detection and multi-device support.

  • Classes: InputManager, KeyboardInfo, MouseInfo, GamePadInfo, IInputProvider
  • Features: Previous/current state tracking, edge detection, gamepad vibration, input abstraction

🔊 Audio

Complete audio system for sound effects and music with automatic resource management.

  • Classes: AudioController
  • Features: Sound effect instances, music playback, volume control, muting, automatic cleanup

🎭 Scenes

Scene management system with automatic resource lifecycle handling.

  • Classes: Scene (abstract base class)
  • Features: Scene-specific content managers, automatic asset cleanup, smooth transitions

🤖 AI

Flexible AI behavior system for implementing game artificial intelligence.

  • Interfaces: IAIBehavior
  • Features: Behavior composition, state machines, patrol AI, extensible design patterns

🛠️ Utilities

Common utilities, logging system, and helper classes.

  • Classes: ILogger (ConsoleLogger, NullLogger), Direction enums
  • Features: Flexible logging, directional movement, type-safe enumerations

Quick Start

1. Create Your Game Class

public class MyGame : Core
{
    public MyGame()
    {
        // Core automatically initializes all subsystems
    }

    protected override void LoadContent()
    {
        // Start with your initial scene
        ChangeScene(new MainMenuScene());
    }
}

2. Implement a Scene

public class GameplayScene : Scene
{
    private PlayerSprite _player;
    private TextureAtlas _playerAtlas;

    public override void LoadContent()
    {
        // Load assets using scene's ContentManager (automatic cleanup)
        _playerAtlas = TextureAtlas.FromXml(Content, "player_atlas.xml");
        _player = new PlayerSprite(_playerAtlas, "player", DirectionMode.FourWay, 
                                  AnimationState.Idle, AnimationState.Walk);
    }

    public override void Update(GameTime gameTime)
    {
        // Handle input and update game objects
        _player.Update(gameTime);

        // Scene transitions
        if (Core.Input.Keyboard.WasKeyJustPressed(Keys.Escape))
        {
            Core.ChangeScene(new MainMenuScene());
        }
    }

    public override void Draw(GameTime gameTime)
    {
        Core.SpriteBatch.Begin();
        _player.Draw(Core.SpriteBatch);
        Core.SpriteBatch.End();
    }
}

3. Handle Input and Audio

// Input with edge detection
if (Core.Input.Keyboard.WasKeyJustPressed(Keys.Space))
{
    player.Jump();
    Core.Audio.PlaySound("jump_sound");
}

// Gamepad support
if (Core.Input.GamePad.IsButtonDown(PlayerIndex.One, Buttons.A))
{
    player.Attack();
}

// Music management
Core.Audio.PlayMusic("background_music");
Core.Audio.SetMusicVolume(0.7f);

Installation

Add the MonoGame Library project to your solution and reference it from your game project:

<ProjectReference Include="..\MonoGameLibrary\MonoGameLibrary.csproj" />

Requirements

  • .NET 9.0
  • MonoGame.Framework.DesktopGL 3.8.2.1105
  • Visual Studio 2022 or compatible IDE

Building

# Build the library
dotnet build

# Build in release mode
dotnet build -c Release

Contributing

When contributing to the MonoGame Library, please:

  1. Follow the established patterns (Core singleton, previous/current state tracking, automatic cleanup)
  2. Add comprehensive documentation to namespace README files
  3. Include usage examples in your documentation
  4. Maintain backward compatibility
  5. Write clean, well-commented code

Design Philosophy

The MonoGame Library prioritizes:

  • Developer Experience: Intuitive APIs and automatic resource management
  • Performance: Built on MonoGame's efficient foundation
  • Flexibility: Interface-based design allows customization
  • Reliability: Consistent patterns and thorough error handling
  • Maintainability: Clear separation of concerns and comprehensive documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.26 108 1/14/2026
1.0.25 82 1/12/2026
1.0.24 85 1/4/2026
1.0.23 78 12/29/2025
1.0.22 136 12/14/2025
1.0.21 149 11/28/2025
1.0.20 163 11/25/2025
1.0.19 166 11/25/2025
1.0.18 160 11/24/2025
1.0.17 169 11/23/2025
1.0.16 168 11/23/2025
1.0.15 125 11/23/2025
1.0.14 294 11/16/2025
1.0.13 257 11/16/2025
1.0.1 128 11/15/2025