MT2D

Monochrome Text 2D Engine

A small C framework for text based programs and games. An 80x25 grid of characters that also draws sprites, plays sound and music, and runs on a real terminal, in a window, on MS-DOS, on a phone, and right here in your browser.

Loading...
Turn your phone to landscape to play.
(In portrait the engine draws its rotated screen.)

Use the arrow keys, Enter, Esc and the number keys, or the buttons above on a phone (landscape works best). On the Graphics screen, T or the Touch keys button shows or hides the on-screen stick and buttons (they appear by themselves on a touch screen). The sound starts muted: press M or the Unmute button (browsers keep audio off until you interact).

This page is an MT2D program

Everything inside the screen above is drawn by the engine itself: the menu, the effects, the sprites, the samples, the piano and the music player. It is the examples/welcome program compiled to WebAssembly with Emscripten. The same source style (and most of the same calls) builds for a terminal or for MS-DOS.

What MT2D offers

Start with plain text and add what you need.

Text first

One 80x25 screen buffer, CP850 characters, box drawing, message boxes, input boxes and menus in a single call each. Great for college projects and simple terminal games.

Graphics when you want them

On SDL and MS-DOS VGA the same program can draw image sprites on top of the text screen: parallax, animation, smooth movement. Sprite_Render_on_Window

Sound and music

WAV and OGG through SDL2_mixer, IMF songs on the OPL2 chip and WAV on the Sound Blaster in MS-DOS, and a PC speaker beep that is emulated where there is no speaker. MT2D_Play_Audio MT2D_Play_Music MT2D_System_Beep

ObjectCore

Objects with a screen position, sprites (ASCII or images), states and wait states, dynamic data types, and Cscript: small scripts attached to each state that can call your own C functions.

Input

Keyboard, touch (basic) and joystick. The joystick API also reads held keys, so several keys work at once and movement is smooth.

Small and portable

The portable engine is ANSI C (C89), split into small source files so you only link what you use. Low RAM usage, and settings are plain defines. Builds with GCC, Clang, Visual Studio, DJGPP and Open Watcom.

Platforms

One program, many systems.

PlatformGraphicsTerminalKeyboardJoystickAudioPC speakerStorage
Windows✓✓✓✓✓✓✓
Linux✓✓✓✓✓✓✓
macOS✓✓✓✓✓✓✓
MS-DOS✓✓✓✓✓✓✓
Android✓–✓✓✓✓✓
Windows Phone✓–✓✓✓✓✓
Web (Emscripten)✓–✓✓✓✓✓

Graphics, controllers and audio files come from SDL2. MS-DOS has its own experimental VGA mode, a keyboard based joystick and OPL2 / Sound Blaster audio. In the browser the text screen is drawn by the SDL backend (there is no real terminal). Details: platforms.md.

Get started

A whole program, and how to build the examples.

Hello, MT2D

#include <MT2D/MT2D.h>
#include <MT2D/MT2D_Display.h>
#include <MT2D/MT2D_Keyboard.h>

int main(void)
{
    MT2D_Init();
    MT2D_Clear_Main_Window();
    insert_string_on_display((char *)"Hello, MT2D!",
                             10, 34, DISPLAY_WINDOW1);
    MT2D_Draw_Window(DISPLAY_WINDOW1);
    MT2D_Keyboard_keytouched();
    return 0;
}

Build the examples

# every example, native
cmake -S examples -B build/examples
cmake --build build/examples
./examples/helloworld/bin/helloworld

# this page (needs the Emscripten SDK)
emcmake cmake -S examples/welcome -B build/welcome
cmake --build build/welcome
python3 -m http.server 8000 \
        --directory examples/welcome/bin

Documentation: Documentation/ · examples/ (one small program per feature) · MIGRATION.md

Made with MT2D

Games and tools built with the engine over the years.