parin README

项目的 README,来自 github.com/Kapendev/parin。合并为一个 markdown 文件:README.md。

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.

Parin demo

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

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;

Major Features

Quick Start

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

Install Without DUB

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

Documentation

Start with the examples folder or the cheatsheet for a quick overview. For more details, see the tour page or dlang.uk/parin. 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:

Videos:

Web Builds

Parin includes a build script for the web in the packages folder. Building for the web requires:

Running the script with DUB:

dub run parin:web

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."
  6. Ignore everything in "Frame options" except "Fullscreen button."

Ideas

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:

Any other libraries that I can use?

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.

How can I test dialogue scripts?

With Rin, a small tool that runs dialogue scripts in the terminal. See packages/rin for how to use it.

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. Use Filter.linear for smooth textures, or Filter.trilinear if they are often drawn much smaller than their real size. See the mipmaps example.

parin (Kapendev/parin)

正在搜索数据库…

148 ·GitHub
这是什么?Parin 是一个用于 D 语言的轻量级 2D 游戏引擎,设计目标是易于配置、便于修改,并内置动画、寻路和屏幕震动等实用功能。
Parin 只是 raylib 的封装,还是别的什么?不只是封装。Parin 是独立的引擎,它把 raylib 作为后端之一;自定义后端正在开发中,但仍处于实验阶段。
我该如何让 Parin 项目跑起来?使用 DUB 安装:新建一个文件夹,在其中运行 Quick Start 命令,即可生成一个带有可见窗口的可运行初始模板。
在 Linux 上使用 Parin,或者要构建网页版,我需要先安装什么?在 Linux 上,需要先安装几个用于声音、图形和输入处理的库(文中提供了 Ubuntu、Fedora、Arch 和 Void 的安装命令)。构建网页版还需要额外安装 LDC 和 Emscripten(推荐版本 4.0.23)。
Parin 自带场景或实体系统,或者脚本语言吗?两者都没有。Parin 不附带场景或实体系统(不过示例展示了如何用 Union 类型自己搭建一个),也没有内置脚本语言,但可以改用 wren-port 或 arsd.script 等第三方 D 语言库。
用 Parin 做的游戏可以发布到哪些平台?Parin 游戏可以构建到 Web、Windows、Linux 和 macOS。
我能把 Parin 游戏发布到 Steam 上,或者加入多人联机吗?可以。Parin 在 parin.bindings 中包含了 Steamworks 和 ENet 的 D 语言绑定,不过你仍需自行下载或编译原生二进制文件。
Parin 支持资源或代码的热重载吗?不支持。这是有意为之,因为作者不优先考虑该功能;如果需要,可以参考 arsd 库。
作者推荐用哪些工具来制作 Parin 游戏?编辑器推荐 Zed(配合 Path Server 扩展实现资源自动补全);关卡用 Tiled;美术用 Pixelorama 或 GIMP;音效用 Bfxr/Jfxr;音乐用 MilkyTracker。
Joka 是什么?Joka 是 Parin 大部分功能所基于的可移植实用库,也可以脱离 Parin 单独使用(例如直接配合 raylib 使用)。
作者
Kapendev
大小
7.1 MB
星标
148
更新
提交Nov 03
时长
2年
提交 · 90 天