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
:
brew install glslang
gamnit is modular, different services of the framework are available through different submodules:
The main entrypoint gamnit
provides 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_core
to update the screen and App::accept_event
to receive user inputs.
flat
provides an easy to use API for 2D games based on sprites.
Clients of this API redefine App::update
to update the game logic and fill lists of sprites with objects to draw.
App::sprites
lists 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 reset_depth(desired_world_units_on_y)
or the z
of its position
App::ui_sprites
lists 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 reset_depth(height_of_reference_display)
.
depth
defines an API for 3D games based on instances of Actor
.
This framework is build upon flat
, see the doc of this submodule first (just above).
As such, clients should still implement update
with the game logic, and fill ui_sprites
for UI elements.
At each frame, elements in the list actors
are drawn to screen.
Each Actor
is composed of a Model
and other information specific to this instance:
position in the world, rotation and scaling.
limit_fps
refines existing services of gamnit to limit the framerate to a customizable value.
keys
provides app.pressed_keys
keeping track of the currently pressed keys.
model_parsers
provides services to read and parse models from the asset folder.
network
provides a simple communication framework for multiplayer client/server games.
accept_scroll_and_zoom
gamnit :: camera_control_android
Two fingers camera manipulation, pinch to zoom and slide to scrollgamnit :: camera_control_linux
Mouse wheel and middle mouse button to control cameraegl
, sdl
and x11
gamnit :: texture_atlas_parser
Tool to parse XML texture atlas and generated Nit code to access subtextures