gamnit: implement app::audio for desktop using SDL2 mixer
[nit.git] / lib / gamnit / README.md
1 Portable game and multimedia framework for Nit
2
3 _gamnit_ is a modular framework to create portable 2D or 3D apps in Nit.
4 It is based on the portability framework _app.nit_ and the OpenGL ES 2.0 standard.
5
6 # System configuration
7
8 To compile the _gamnit_ apps packaged with the Nit repositoy on GNU/Linux you need to install the dev version of a few libraries and some tools.
9 Under Debian 8.2, this command should install everything needed:
10
11 ~~~
12 apt-get install libgles2-mesa-dev libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev inkscape mpg123
13 ~~~
14
15 Under Windows 64 bits, using msys2, you can install the required packages with:
16
17 ~~~
18 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
19 ~~~
20
21 # Services by submodules
22
23 _gamnit_ is modular, different services of the framework are available through different submodules:
24
25 * The main entrypoint `gamnit` provides low-level abstractions over some services of OpenGL ES 2.0, like textures, shaders and programs.
26   It defines the basic methods to implement in order to obtain a working game:
27   `App::frame_core` to update the screen and `App::accept_event` to receive user inputs.
28
29 * `flat` provides an easy to use API for 2D games based on sprites.
30   Clients of this API redefine `App::update` to update the game logic and fill lists of sprites with objects to draw.
31
32   `App::sprites` lists the sprites of the game world, they are drawn form the point of view of the `world_camera`.
33   This camera can be moved around in the world by updating the x and y of its `position`,
34   and the zoom can easily be set using `reset_depth(desired_world_units_on_y)` or the `z` of its `position`
35
36   `App::ui_sprites` lists the UI sprites drawn from the point of view of `ui_camera`.
37   By default, this camera is pixel-perfect with the origin in the top left corner of the window.
38   However to support screens with different DPI, it is recommended to standardize
39   the display size using `reset_depth(height_of_reference_display)`.
40
41 * `depth` defines an API for 3D games based on instances of `Actor`.
42
43   This framework is build upon `flat`, see the doc of this submodule first (just above).
44   As such, clients should still implement `update` with the game logic, and fill `ui_sprites` for UI elements.
45
46   At each frame, elements in the list `actors` are drawn to screen.
47   Each `Actor` is composed of a `Model` and other information specific to this instance:
48   position in the world, rotation and scaling.
49
50 * `limit_fps` refines existing services of _gamnit_ to limit the framerate to a customizable value.
51
52 * `keys` provides `app.pressed_keys` keeping track of the currently pressed keys.
53
54 * `model_parsers` provides services to read and parse models from the asset folder.
55
56 * `network` provides a simple communication framework for multiplayer client/server games.