Mintaro 一个小框架用于制作简单,复古风格的游戏(mintaro红酒)

网友投稿 589 2022-10-13

Mintaro 一个小框架用于制作简单,复古风格的游戏(mintaro红酒)

Mintaro 一个小框架用于制作简单,复古风格的游戏(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, rightA, BStart, SelectSound groups with independant volume controls.A simple API.Supports Windows and Linux.

Features Coming Soon

Fullscreen modeLine rasterizationTriangle rasterization (solid and textured)Rotated spritesMore optimizations, especially for graphicsMore platformsMore flexibility for input: Support for binding different keys to the same button.Support for general keyboard controls (in addition to buttons)Support for mouse controlsSupport 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.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:[蓝桥杯]2017蓝桥省赛B组题目及详解
下一篇:[机器学习笔记]幂次学院西瓜书集训营-第一章机器学习简介
相关文章

 发表评论

暂时没有评论,来抢沙发吧~