Skip to content
/ mgc Public

MGC is a lightweight library for building small games and gadgets, especially on embedded systems.

License

Notifications You must be signed in to change notification settings

nyannkov/mgc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mgc

Overview

mgc is a lightweight, embedded-friendly library for building small games and gadgets.

Instead of being a full-fledged game engine, mgc provides a set of modular tools
designed to simplify graphics, input, and asset handling in embedded environments.

+----------------------------------------------+
|                    mgc                       |
|                                              |
|  +------------+    +----------------------+  |
|  |  mgc_c     |    |       mgc_cpp        |  |
|  |  C core    |    |                      |  |
|  +------------+    |  +----------------+  |  |
|                    |  |  platform      |  |  |
|                    |  |  application–  |  |  |
|                    |  |  driver I/F    |  |  |
|                    |  +--------|-------+  |  |
|                    +-----------|----------+  |
+--------------------------------|-------------+
                                 |
                                 v
                      +------------------------+
                      |  mgc_drivers           |
                      |  (optional)            |
                      |                        |
                      |  drivers / hardware    |
                      +------------------------+

The platform layer provides interfaces that connect application logic to platform-specific drivers, without owning hardware resources.

Graphics

  • Color format: RGB565
  • Color mode: Indexed color

Font Support

  • Font format: BDF (Bitmap Distribution Format)
  • Maximum font height: 16 pixels

Example: Drawing a Sprite

This example shows how to draw a sprite using MGC. A tileset generated by MGC tools is assigned to a BasicSprite, and the sprite is rendered into an application-managed frame buffer. The frame buffer is not owned by MGC and can be freely transferred or reused by the application.

// Frame buffer for the dot-matrix display (6x10, RGB565)
mgc::graphics::Color buffer[6 * 10];
mgc::graphics::Framebuffer fb(buffer, 6, 10);

// Sprite used for tile rendering
mgc::parts::BasicSprite sprite;

// Register the tileset to be rendered (generated as const data)
sprite.set_tileset(tileset_chick);

// Set the tile index to render
sprite.set_tile_index(0);

// Set the sprite position (top-left of the tile, Y-down coordinates)
sprite.set_position({0, 0});

// Draw the sprite into the external frame buffer
sprite.draw(fb);

// The framebuffer can then be transferred by a display driver
// display.transfer(buffer);

Project Structure

root/
├── src/        # Core library source files
│   ├── mgc/        # C interface (platform-agnostic)
│   └── mgc_cpp/    # C++ wrapper (type-safe, heapless)
├── devtest/    # Experimental code and prototypes for internal development
├── drivers/    # Platform-specific drivers (display, input, sound, etc., optional)
├── external/   # External libraries and git submodules
├── scripts/    # Initialization and utility scripts, including setup and small tools
├── test/       # Test code
├── tools/      # Asset generator tools such as font and tileset converters
├── CMakeLists.txt
├── LICENSE
└── README.md

Setup

After cloning the repository, change into the project directory and run the setup script to initialize external dependencies:

cd mgc
git submodule update --init --recursive
python3 scripts/setup_assets.py

This script downloads and prepares external assets such as fonts and other resources required for building the project.

Using Raspberry Pi Pico

If you plan to build for the Raspberry Pi Pico platform, you need to set up the Pico SDK beforehand. Please follow the official Pico SDK setup instructions to configure your development environment.


License

mgc is released under the MIT License.
See the LICENSE file for details.

Note

Auto-generated files such as fonts, maps, and tilesets should comply with the license of their original data sources.

Some drivers under the drivers/ directory make use of third-party libraries located in the external/ directory.
These external modules are included as Git submodules and are maintained under their own respective licenses
(e.g., MIT, BSD, or GPL). Please refer to each submodule's documentation and license file for more information.

About

MGC is a lightweight library for building small games and gadgets, especially on embedded systems.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published