GithubHelp home page GithubHelp logo

mintaro's Introduction

Mintaro

Mintaro is a tiny framework for making simple, retro style games. It's not intended to be a full-featured game engine, but is instead focused on simplicity and just making it fun to make simple games.

C/C++, single file, public domain.

Features

  • A single file with optional dependencies to extend functionality.
  • No external dependencies except for the standard library and necessary platform libraries like XLib and Win32.
  • Software rendering, with up to 256 colors and a customizable palette.
  • Uncapped framerate.
  • Custom resolutions of any dimensions.
  • 8 buttons of input
    • Up, down, left, right
    • A, B
    • Start, Select
  • Sound groups with independant volume controls.
  • A simple API.
  • Supports Windows and Linux.

Features Coming Soon

  • Fullscreen mode
  • Line rasterization
  • Triangle rasterization (solid and textured)
  • Rotated sprites
  • More optimizations, especially for graphics
  • More platforms
  • More flexibility for input:
    • Support for binding different keys to the same button.
    • Support for general keyboard controls (in addition to buttons)
    • Support for mouse controls
    • Support for 360 controllers

Usage

Mintaro is a single-file library. To use it, just #include "mintaro.h" like you would any other header file and then in one source file do the following:

#define MINTARO_IMPLEMENTATION
#include "mintaro.h"

Make sure you don't define the implementation in more than one translation unit.

Mintaro includes a built-in loader for TGA images, but you can enable loading of additional formats via stb_image by simply including it before the implementation of Mintaro, like this:

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"

#define MINTARO_IMPLEMENTATION
#include "mintaro.h"

A copy of stb_image.h is included in the "extras" directory.

Mintaro includes a built-in loader for WAV sounds, but you can enable loading of Vorbis and FLAC sounds by #including stb_vorbis.c and/or dr_flac.h before the implementation of Mintaro, in the same was as mentioned above for stb_image.h.

Examples

Mintaro is focused on simplicity. Here's a quick example.

void on_step(mo_context* pContext, double dt)
{
    // Input.
    if (mo_was_button_pressed(MO_BUTTON_A)) {
        if (CanShoot()) {
            mo_play_sound_source(pContext, pGunshotSoundSource);
        }
    }
    
    // Simulation.
    UpdateCharacter(dt);

    // Drawing.
    mo_clear(pContext, clearColorIndex);
    mo_draw_image(pContext, characterPosX, characterPosY, pCharacterSpriteSheet, 0, 0, 64, 64);
    mo_draw_textf(pContext, 0, 0, textColorIndex, "Health: %d", characterHealth);
}

int main()
{
    mo_context* pContext;
    if (mo_init(NULL, "My Game's Name", on_step, pUserData, &pContext) {
        return -1;
    }
    
    // Load some resources.
    mo_sound_source* pMusicSource;
    mo_sound_source_load(pContext, "data/my_music.wav", &pMusic);
    
    mo_image* pCharacterSpriteSheet;
    mo_image_load(pContext, "data/character.tga", &pCharacterSpriteSheet);
    
    
    // Play some music in a loop.
    mo_sound* pMusic;
    mo_sound_create(pContext, pMusicSource, NULL, &pMusic);
    mo_sound_play(pMusic, MO_TRUE);
    
    int result = mo_run(pContext);
    
    mo_uninit(pContext);
    return result;
}

You can also find a "Hello, World!" example in the "examples" folder.

mintaro's People

Contributors

mackron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.