Show HN: Parin – 一个介于 raylib 和 Godot 之间的 2D 游戏引擎,使用 Dlang 编写
Show HN: Parin – A 2D game engine between raylib and Godot, written in Dlang

原始链接: https://github.com/Kapendev/parin

Parin 是一款面向 D 语言的轻量、代码驱动的 2D 游戏引擎,介于 raylib 这样的小型库与 Godot 这样的大型引擎之间。它提供灵活的内存管理(GC 可选)、基于 Joka 构建的模块化基础,以及开箱即用的功能,如像素级物理、灵活的对话系统、图集动画、瓦片地图和 UI 库(开发中),还有 Box2D、Steamworks、ENet 和 microui 等额外组件。它支持 Web、Windows、Linux 和 macOS。 通过 DUB 安装:`dub init -t parin`,然后 `dub run`;模板包括 basic 和 entity。Linux 需要若干用于声音、图形和输入的开发库。Web 构建需要 LDC 和 Emscripten。文档可通过示例、速查表、导览和 DDOX 获取。 FAQ 说明:没有内置场景/实体或脚本系统(提供示例),不支持热重载,资源可自由使用,raylib 仅作为后端(自定义后端为实验性),支持高清游戏。可通过附带的绑定实现 Steam 和多人游戏发布。

Hacker News 新 | 过去 | 评论 | 提问 | 展示 | 工作 | 提交 登录 Show HN:Parin —— 一个介于 raylib 和 Godot 之间的 2D 游戏引擎,用 D 语言编写 (github.com/kapendev) 10 分,由 Kapendev 发布于 2 小时前 | 隐藏 | 过去 | 收藏 | 2 条评论 帮助 Kapendev 2 小时前 [–] Parin 是一个我开发了大约两年的 2D 游戏引擎。 回复 doublerabbit 23 分钟前 | 父评论 [–] 这很酷。创作做得很好。 回复 考虑申请 YC 2027 冬季批次!申请开放至 11 月 2 日。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

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.

Parin demo

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. Its main ideas are:

  • Code-driven design: No engine-mandated architecture, so gameplay code can be structured however fits the game.
  • Flexible abstraction: Garbage collection is available for convenience, with the option to drop to manual management or avoid it entirely.
  • Modular foundation: Most of Parin is built on Joka, a portable utility library that can be used on its own (see this raylib example).
  • Batteries included: Sensible defaults for common needs (animation helpers, timers, etc.).

Basic code example:

import parin;

// Called every frame while the game is running.
bool hello(float dt) {
    lockResolution(320, 180);
    drawText("Helloo!!!", mouse);
    return false;
}

// Creates a main function that calls the given function.
mixin runDemo!hello;
  • Pixel-perfect physics engine
  • Flexible dialogue system
  • Atlas-based animation library
  • Efficient tile map structures
  • Simple UI library (WIP)
  • Includes extras like Box2D, Steamworks, ENet, and microui
  • Support for Web, Windows, Linux, and macOS

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

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

Create a new folder and run the following to...

  1. Prepare the folder:

    git clone --depth 1 https://github.com/Kapendev/parin parin_package
    ./parin_package/scripts/prepare
    # Or: .\parin_package\scripts\prepare.bat
  2. 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

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

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

Articles:

Parin includes a build script for the web in the packages folder. Building for the web requires LDC and Emscripten (version 4.0.23 is recommended). While installing LDC, unpack ldc2-X.Y.Z-addon-emscripten.tar.xz from the same releases page into the LDC installation folder.

Running the script with DUB:

Without DUB:

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

API:

Usage:
  dub run parin:web -- [flags] [libs]
Flags:
  -help     Show this.
  -betterc  Use the `-betterC` flag.
  -release  Use the `-release` flag.
  -build    Avoid emrun after a successful build.
Libs:
  Any non-flag argument is linked as an extra library.
  Example: dub run parin:web -- web/libbox2d.a

Uploading to itch.io:

  1. Open the web folder.
  2. Select the index.* files and add them to a ZIP file.
  3. Go to itch.io and create a new project.
  4. Under "Kind of project", choose "HTML."
  5. Upload the ZIP file and enable the option "This file will be played in the browser."

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

Small extras that don't belong in the core can live in the addons folder as single-file D libraries. Open a PR and add the file there.

Frequently Asked Questions

Is there a list of games made with Parin?

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 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 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.
  • Gamut: Image encoding and decoding library.
  • gameserver: Simple game server for toying with online games.

Can I release on Steam or make multiplayer games?

Yes. Parin includes bindings for Steamworks and ENet in parin.bindings. See the integration examples. The binaries themselves are not included, so they need to be downloaded or built and linked separately.

For Zed, install the Path Server extension to get autocomplete for paths inside the assets folder.

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 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 one of its backends. A custom backend is being worked on, but it's still experimental. Contributions are welcome.

Can I use Parin for HD games?

Yes.

联系我们 contact @ memedata.com