Portable game and multimedia framework for Nit
gamnit is a modular framework to create portable 2D or 3D apps in Nit. It is based on the portability framework app.nit and the OpenGL ES 2.0 standard.
To compile the gamnit apps packaged with the Nit repository on GNU/Linux you need to install the dev version of a few libraries and some tools. On Debian 8.2, this command should install everything needed:
apt-get install libgles2-mesa-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev inkscape
On Windows 64 bits, using msys2, you can install the required packages with:
pacman -S mingw-w64-x86_64-angleproject-git mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer
While macOS isn't supported, it can create iOS apps.
You need to install and setup Xcode, and you may install the GLSL shader validation tool via
brew install glslang
Services by submodules
gamnit is modular, different services of the framework are available through different submodules:
The main entrypoint
gamnitprovides low-level abstractions over some services of OpenGL ES 2.0, like textures, shaders and programs. It defines the basic methods to implement in order to obtain a working game:
App::frame_coreto update the screen and
App::accept_eventto receive user inputs.
flatprovides an easy to use API for 2D games based on sprites. Clients of this API redefine
App::updateto update the game logic and fill lists of sprites with objects to draw.
App::spriteslists the sprites of the game world, they are drawn form the point of view of the
world_camera. This camera can be moved around in the world by updating the x and y of its
position, and the zoom can easily be set using
App::ui_spriteslists the UI sprites drawn from the point of view of
ui_camera. By default, this camera is pixel-perfect with the origin in the top left corner of the window. However to support screens with different DPI, it is recommended to standardize the display size using
depthdefines an API for 3D games based on instances of
This framework is build upon
flat, see the doc of this submodule first (just above). As such, clients should still implement
updatewith the game logic, and fill
ui_spritesfor UI elements.
At each frame, elements in the list
actorsare drawn to screen. Each
Actoris composed of a
Modeland other information specific to this instance: position in the world, rotation and scaling.
limit_fpsrefines existing services of gamnit to limit the framerate to a customizable value.
app.pressed_keyskeeping track of the currently pressed keys.
model_parsersprovides services to read and parse models from the asset folder.
networkprovides a simple communication framework for multiplayer client/server games.