Skip to content

Repository files navigation

Parin

A delightfully simple 2D game engine for the D programming language. It's easy to set up, hackable, and comes with the essentials built in.

Some games made with Parin:

Worms Within Runani
Worms Within Runani

Why Parin

Parin sits somewhere between a small library like raylib and a big engine like Godot. It offers more direction than small libraries, but far less overhead than big engines. It mainly focuses on:

  • Code-driven design: No engine-mandated architecture, so code can be structured however fits the game.
  • Batteries included: Arcady physics, debug UI, fixed aspect ratio...
  • Flexible abstraction: Garbage collection is available for convenience, with the option to drop to manual management or avoid it entirely when needed.
  • Modular foundation: Most of Parin is built on Joka, a portable utility library that can be used directly without the engine. A raylib example using Joka is available on Itch.

Major Features

  • Pixel-perfect physics engine
  • Flexible dialogue system
  • Atlas-based animation library
  • Efficient tile map structures
  • Intuitive UI library (WIP)
  • Includes extras like microui and memory allocators (tracking, frame, arena)
  • Support for Windows, Linux, Web, and macOS

Basic Window Example

import parin;

// Called once when the game starts.
void ready() {
    lockResolution(320, 180);
}

// Called every frame while the game is running.
// If true is returned, then the game will stop running.
bool update(float dt) {
    drawText("Hello world!", Vec2(8));
    return false;
}

// Called once when the game ends.
void finish() {}

// Creates a main function that calls the given functions.
mixin runGame!(ready, update, finish);

Quick Start

This section shows how to install Parin using DUB. Create a new folder and run inside the following commands:

dub init -t parin
dub run

If everything is set up correctly, a window will appear showing a simple message. Available starting templates:

dub init -t parin -- basic
dub init -t parin -- entity

Install Without DUB

Create a new folder and run inside the following commands.

Prepare the folder:

git clone --depth 1 https://github.com/Kapendev/parin parin_package
./parin_package/scripts/prepare
# Or: .\parin_package\scripts\prepare.bat

Run the project:

./parin_package/scripts/run
# Or: .\parin_package\scripts\run.bat
# Or: ./parin_package/scripts/run ldc2 macos
# Or: ./parin_package/scripts/run opend

Required Libraries on Linux

Some libraries for sound, graphics, and input handling are required before using Parin on Linux. Below are installation commands for some Linux distributions.

Ubuntu:

sudo apt install libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev libwayland-dev libxkbcommon-dev

Fedora:

sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel libatomic

Arch:

sudo pacman -S alsa-lib mesa libx11 libxrandr libxi libxcursor libxinerama

Void:

sudo xbps-install make alsa-lib-devel libglvnd-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel mesa MesaLib-devel

Documentation

Start with the examples folder or the cheatsheet for a quick overview. For more details, see the tour page or the DDOX page. The DDOX documentation engine can also be used locally to create an overview with:

git clone --depth=1 https://github.com/Kapendev/parin parin_package
cd parin_package
dub run -b ddox

Ideas

If you notice anything missing or want to contribute, feel free to open an issue! You can also share things in the GitHub discussions. Most ideas are welcome, except ECS or hot reloading.

Devlogs & Articles

Recommended Tools

While it is possible to use any tool with Parin, these open-source ones are simple to use and work well:

Web Builds

Parin includes a build script for the web in the packages folder. Building for the web requires Emscripten (version 4.0.23 is recommended).

Running the script with DUB:

dub run parin:web

Without DUB:

./parin_package/scripts/web
# Or: .\parin_package\scripts\web.bat

Projects requiring the D runtime can be built using the gc flag provided by the build script. This flag also requires OpenD. Note that exceptions are not supported and that currently some DUB related limitations apply like having to include all dependencies inside the source folder. Make sure opend install xpack-emscripten has been run at least once before using it.

Using the flag with DUB:

dub run parin:web -- gc

Without DUB:

./parin_package/scripts/web gc
# Or: .\parin_package\scripts\web.bat gc

To speed up build times, use the debug flag. The build flag can be used to build the project without running the game.

Uploading Web Builds to itch.io

  1. Open the web folder.

  2. Select these files and add them to a ZIP file:

    favicon.ico
    index.data
    index.html
    index.js
    index.wasm
    
  3. Go to itch.io and create a new project.

  4. Under "Kind of project", choose "HTML."

  5. Upload the ZIP file.

  6. Enable the option "This file will be played in the browser."

  7. Save the changes.

The web build script provides the itch flag to automate the first two steps. This flag currently only works on Linux. Contributions to add Windows and macOS support are welcome.

Frequently Asked Questions

Is there a list of games made with Parin?

Yes. Check the projects page.

Does Parin have a scene or entity system?

No. However, there are examples of how to build them using the Union type in the examples folder:

Does Parin have a UI library?

Yes. However, it's WIP and will change in the future. Check the examples folder for more information about how the current version works.

The following libraries are also compatible with Parin:

  • microui-d: A tiny immediate-mode UI library. A custom fork is included by default in parin.addons.
  • Fluid: A declarative cross-platform user interface library.

Does Parin have a scripting language?

No. The following projects might be useful:

  • wren-port: A port of the Wren programming language to D.
  • arsd.script: The language is based on a hybrid of D and Javascript.
  • bindbc-lua: Static & dynamic D bindings to the C API of Lua.

Any other helpful libraries that I can use?

  • arsd.ini: INI configuration file support.
  • newsdlang: SDLang/XDL configuration file support.
  • dex-cf: CF (Configuration File) support.
  • dtiled: D language parser for Tiled map files.
  • text-mode: Virtual text mode with 8x8 Unicode font and markup language.
  • Inochi2D: A library for realtime 2D puppet animation. Using it with Parin = using the current Parin backend directly.
  • Gamut: Image encoding and decoding library.
  • gameserver: Simple game server for toying with online games.

How can I load an asset outside of the assets folder?

Call setIsUsingAssetsPath(false) to disable the default behavior. Or setAssetsPath(assetsPath.pathDirName) to load from the executable's folder.

How do I use the Vec2 type?

The Vec2 type is provided by the Joka library, which Parin depends on. An example using this type can be found in the Joka repository. It's a good idea to learn how Joka works in general.

How can I hot reload assets or code?

Hot reloading is not supported out of the box because I (Kapendev) don't care about that feature. The arsd libraries may help.

Are the Parin assets free to use?

Yes. Be sure to check the associated README for any licensing notes.

Is Parin a raylib wrapper?

No. Raylib is the current backend. A custom backend may be added in the future, but it's not a priority. Contributions are welcome.

What are Parin's priorities?

The goal is a smooth experience, similar to Godot or Unity. Its main design inspirations are Processing and RPG Maker.

Can I use Parin for HD games?

Yes.

About

A delightfully simple 2D game engine.

Topics

Resources

Stars

90 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages