🎮 C framework I wrote for my video games. It runs natively on Linux and FreeBSD, and can be cross-compiled for Windows, Emscripten, GP2X, Wiz, Caanoo, and Open Pandora.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin a2x_component puts each a_component_new argument on a new line. Dec 6, 2018
make Restore Geany tags generation. Nov 26, 2018
media Simplify text drawing. Fonts are stored in a sprites grid modeled aft… Nov 26, 2018
src Font and Output modules use larger text buffers. Dec 10, 2018
.gitignore Generate default font and console icons code files for each platform … Jan 5, 2018
.travis.yml Set A2X_PATH in travis.yml script. Nov 18, 2018
COPYING.LESSER Softer colors and new a2x logo. Move code license files to root folde… Sep 21, 2016
README.markdown Small changes to Readme code snippets. Nov 7, 2018
dev.sh Makefile.pandora pnd target copies the source assets dir to the pnd p… Oct 28, 2018


a2x Build Status

a2x is a C framework I wrote for my video games. It runs natively on Linux and FreeBSD, and can be cross-compiled for Windows, GP2X, Wiz, Caanoo, Open Pandora, and HTML5.


sudo apt install git build-essential python3
sudo apt install libpng-dev libsdl2-dev libsdl2-mixer-dev

cd ~
git clone git://github.com/alxm/a2x.git

export A2X_PATH="$HOME/a2x"
export PATH="$PATH:$A2X_PATH/bin"

cd a2x/make/a2x
make -j

Hello, World! Project

a2x_new generates a small one-file project that draws a square which you can move with the arrow keys or a gamepad.

a2x_new hello
cd hello/make/
make run

Starter Project Screenshot

All the code is in hello/src/main.c:

#include <a2x.h>

    a_settings_stringSet(A_SETTING_APP_TITLE, "hello");
    a_settings_stringSet(A_SETTING_APP_VERSION, "1.0");

    static struct {
        int x, y;
        AButton *up, *down, *left, *right;
    } context;

        context.x = a_screen_widthGet() / 2;
        context.y = a_screen_heightGet() / 2;

        context.up = a_button_new();
        a_button_bind(context.up, A_KEY_UP);
        a_button_bind(context.up, A_BUTTON_UP);

        context.down = a_button_new();
        a_button_bind(context.down, A_KEY_DOWN);
        a_button_bind(context.down, A_BUTTON_DOWN);

        context.left = a_button_new();
        a_button_bind(context.left, A_KEY_LEFT);
        a_button_bind(context.left, A_BUTTON_LEFT);

        context.right = a_button_new();
        a_button_bind(context.right, A_KEY_RIGHT);
        a_button_bind(context.right, A_BUTTON_RIGHT);

        if(a_button_pressGet(context.up)) {
        } else if(a_button_pressGet(context.down)) {

        if(a_button_pressGet(context.left)) {
        } else if(a_button_pressGet(context.right)) {


        a_draw_rectangle(context.x - 40, context.y - 40, 80, 80);

    a_state_push(drawBox, "Draw Box");

Cross-Compile for Other Platforms

I originally wrote a2x to make games for the Linux-based GP2X handheld. The following targets are also supported:

  • Emscripten (HTML5)
  • GPH SDK (Caanoo)
  • MinGW (Windows)
  • Open2x SDK (GP2X, Wiz)
  • Pandora SDK (Open Pandora)

Edit ~/.config/a2x/sdk.config with your SDK paths:

cd a2x/make/a2x
make config                    # Create default sdk.config file
nano ~/.config/a2x/sdk.config  # Edit with your own SDK paths
make config                    # Process changes
make -j -f Makefile.gp2x       # Cross-compile for GP2X or other


Copyright 2010-2018 Alex Margarit (alex@alxm.org)

  • Code licensed under GNU LGPL3 (see COPYING and COPYING.LESSER)
  • Graphics licensed under CC BY-NC-ND 4.0 (see media/CC-BY-NC-ND)

a2x is a small project that supports my other personal projects. In the interest of focus and simplicity, it is a solo endeavor.