rrbox / ecs-swift

Entity Component System for swift
MIT License
3 stars 0 forks source link

README の作成と更新 #24

Closed rrbox closed 4 months ago

rrbox commented 9 months ago

何書こうかしら


rrbox commented 9 months ago

What is ecs-swift?


Swift で Entity Component System (ECS) を実装したライブラリです。SpriteKit や SceneKit などのフレームワークで ECS 設計のゲームを開発するために使用します。

これは Rust の ECS ライブラリである bevy engine から多大なる影響を受けています!とくにecs-swiftは protocol 指向を意識して設計されており、コンポーネントを構造体で定義することができます!

ただし制作者本人は、bevy engine の完全コピーではなく、Swift で作った劣化版だと認識しています。詳しくは、Wiki の bevy engine の劣化版としての ecs-swift を参照してください。


ecs-swift is a library that implements the Entity Component System (ECS) in Swift. It is used for developing games with ECS design in frameworks such as SpriteKit and SceneKit.

This library has been greatly influenced by the ECS library of Rust, the Bevy engine! Particularly, ecs-swift is designed with a focus on protocol-oriented programming, allowing you to define components using structures!

However, the creator acknowledges that ecs-swift is not a complete copy of the Bevy engine but rather a lite version created in Swift. For more details, please refer to the Wiki for ecs-swift as a lite version of the Bevy engine.


修正案

Bevy -> Bevy ECS

Bevy ECS は Rust 製ゲームエンジンである Bevy のためクレートです。しっかり区別した方がいいかもしれません。

rrbox commented 9 months ago

注意書き Warning

私はこのパッケージの更新をあまり積極的に行っていません。本当にごめんなさい。特に、私は個人で 2D ゲームを制作することに注力していることもあり、3D ゲームに対するサポートは希薄となっています。またそのような背景から、積極的に新しい機能を迅速に取り入れることは稀だと認識してください。

しかし、全く更新しないというわけではなく、必要に応じてメンテナンスし、機能も追加し、リファクタリングし、デバッグしていく予定です(ゆっくりかもしれません)。意見・要望などがあればぜひ、 Discussions へ!

このツールの開発者 @rrbox より


I believe I may not be able to actively update this package very often. I sincerely apologize for that. The reason behind this is my personal focus on creating 2D games. Please understand that incorporating new features promptly is rare for me. Additionally, due to this background, support for 3D games is limited.

However, it doesn't mean that I won't update it at all. I plan to maintain, add features, refactor, and debug as needed (though it might be at a slower pace). If you have any opinions or requests, please feel free to share them in the Discussions (under construction)!

From the developer of this tool, @rrbox.

rrbox commented 9 months ago

ライセンス契約

以下に基づいてライセンスされています。

「Warning」でも述べたように、制作者はパッケージ更新にあまり着手できていません。もし更新を待ちきれない場合、あるいは制作者の方針から外れた実装を求める場合、「あなたの ecs-swift」へと改造する選択肢も忘れないでください。


License

This is licensed under the following:

As mentioned in the "Warning," it seems that the creator may not be actively working on package updates. If you cannot wait for updates or if you seek implementations outside the creator's direction, don't forget the option of modifying "this ecs-swift" into "your ecs-swift."

rrbox commented 9 months ago

Examples

import ECS

Create Component

struct Position: Component {
    var x: CGFloat
    var y: CGFlaot
}

Create System

func moveableEntitySpawnSystem(commands: Commands) {
    commands.spawn()
        .addComponent(Position(x: 50, y: 100))
}

func movementSystem(query: Query<Position>, deltaTime: Resource<DeltaTime>) {
    query.update { _, position, deltaTime in
        position.value.x += 120 * deltaTime.resource
    }
}

func presentPositionSystem(query: Query<Position>) {
    query.update { _, position in
        print(position.value)
    }
}

Create World

let world = World()
    .addSystem(.startUp, moveableEntitySpawnSystem(commands:))
    .addSystem(.update, movementSystem(query:deltaTime:))
    .addSystem(.update, presentPositionSystem(query:))

Run World (SpriteKit)

import SpriteKit
import ECS

class Scene: SKScene {
    override func didMove(to view: SKView) {
        world.setUp()
    }

    override func update(_ currentTime: TimeInterval) {
        world.update(currentTime)
    }
}

詳しい解説は Wiki にて!


Detailed explanations can be found in the Wiki (under construction)!

rrbox commented 9 months ago

Getting Started

いらないかも?

SwiftPackage で導入するときのおまじないでも書いておきましょう。

Requirements

Swift package

// swift-tools-version:5.8

import PackageDescription

let package = Package(
  name: "Your project",
  dependencies: [
    .package(url: "https://github.com/rrbox/ecs-swift.git", from: "0.1.0")
  ],
  targets: [
    .target(name: "Your project", dependencies: ["ECS", "PlugIns"])
  ]
)
rrbox commented 8 months ago

バッジ

GitHub issues GitHub License (main branch) GitHub License (develop branch) Swift (sample) Swift (release latest)

rrbox commented 4 months ago

0.1 の README はこれで完成とします。 メンテナンスは今後も継続します。