搜尋套件、儲存庫與 APP 分類

套件詳情v0.10.1

dartemis

用於遊戲開發的實體系統框架。基於 Artemis。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
140
喜歡數
13
Pub 分數
160

安裝套件

flutter pub add dartemis

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Dartemis 是一個輕量級的實體-組件-系統(ECS)框架,用於 Dart 遊戲開發,靈感來自 Artemis 框架。它提供了一種結構化的方法來管理遊戲實體、組件和系統,促進效能與可擴展性。專為與 Flutter 一起使用而設計,支援多個平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。該框架透過關注點分離實現高效的資料驅動遊戲邏輯,非常適合複雜的遊戲架構。開發者可以輕鬆透過自訂系統和組件擴展功能。

適用情境

  • 建構2D/3D遊戲
  • 管理大量遊戲實體
  • 實施資料驅動的遊戲邏輯
  • 創建模組化遊戲系統
  • 優化遊戲迴圈中的效能

主要特色

  • 實體-組件-系統架構
  • 高性能和低記憶體開銷
  • 跨平台支援
  • 可擴充的系統和組件模型
  • 內建事件和查詢系統

適合對象

  • 使用Flutter的遊戲開發者
  • 需要可擴展實體管理的項目
  • 建構複雜遊戲機制的團隊
  • 尋求 ECS 最佳實務的開發人員
  • 效能關鍵的應用程式

使用建議

  • 需要理解 ECS 模式
  • 初學者的學習曲線更陡峭
  • 有限的內建圖形或音訊支援
  • 不是一個完整的遊戲引擎
  • 最佳搭配額外的調試工具使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

dartemis

Build Status Coverage Status Pub

Content

About

dartemis is a Dart port of the Entity System Framework Artemis.

The original has been written in Java by Arni Arent and Tiago Costa and can be found here: https://gamadu.com/artemis/ (archived) with the source available here: https://code.google.com/p/artemis-framework/

Ports for other languages are also available:

  • C#: https://github.com/thelinuxlich/artemis_CSharp
  • Python: https://github.com/kernhanda/PyArtemis

Some useful links about what an Entity System/Entity Component System is:

Getting started

  1. Add dartemis to your project by adding it to your pubspec.yaml:

    dependencies:
      dartemis: any
    
  2. Import it in your project:

    import 'package:dartemis/dartemis.dart';
    
  3. Create a world:

    final world = World();
    
  4. Create an entity from a list of components. Entities with different components will be processed by different systems:

    world.createEntity([
      Position(0, 0), 
      Velocity(1, 1),
    ]);
    

    A Component is a pretty simple structure and should not contain any logic:

    class Position extends Component {
      num x, y;
      Position(this.x, this.y);
    }
    

    Or if you want to use a PooledComponent:

    class Position extends PooledComponent {
      late num x, y;
     
      Position._();
      factory Position(num x, num y) {
        final position = Pooled.of<Position>(() => Position._())
          ..x = x
          ..y = y;
        return position;
      }
    }
    

    By using a factory constructor and calling the static function Pooled.of, dartemis is able to reuse destroyed components and they will not be garbage collected.

  5. Define a systems that should process your entities. The Aspect defines which components an entity needs to have in order to be processed by the system:

    class MovementSystem extends EntityProcessingSystem {
      late Mapper<Position> positionMapper;
      late Mapper<Velocity> velocityMapper;
    
      MovementSystem() : super(Aspect.forAllOf([Position, Velocity]));
    
      void initialize() {
        // initialize your system
        // Mappers, Systems and Managers have to be assigned here
        // see dartemis_builder if you don't want to write this code
        positionMapper = Mapper<Position>(world);
        velocityMapper = Mapper<Velocity>(world);
      }
    
      void processEntity(Entity entity) {
        Position position = positionMapper[entity];
        Velocity vel = velocityMapper[entity];
        position
          ..x += vel.x * world.delta
          ..y += vel.y * world.delta;
      }
    }
    

    Or using dartemis_builder

    part 'filename.g.part';
    
    @Generate(
      EntityProcessingSystem,
      allOf: [
        Position,
        Velocity,
      ],
    )
    class SimpleMovementSystem extends _$SimpleMovementSystem {
      @override
      void processEntity(Entity entity, Position position, Velocity velocity) {    
        position
          ..x += velocity.x * world.delta
          ..y += velocity.y * world.delta;
      }
    }
    
  6. Add your system to the world:

    world.addSystem(MovementSystem());
    
  7. Initialize the world:

    world.initialize();   
    
  8. Usually your logic requires a delta, so you need to set it in your game loop:

    world.delta = delta;
    
  9. In your game loop you then process your systems:

    world.process();
    

Documentation

API

Reference Manual

Example Games using dartemis

  • darteroids - Very simple example included in the example folder of dartemis, (Source)
  • Shapeocalypse - A fast paced reaction game using Angular, WebAudio and WebGL
  • damacreat - An iogame similar to agar.io about creatures made of dark matter (circles) consuming dark energy (circles) and other dark matter creatures (circles), which can shoot black holes (circles)

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。