Dartemis는 Artemis 프레임워크에서 영감을 받은 Dart로 게임 개발을 위한 경량 엔티티-컴포넌트-시스템(ECS) 프레임워크입니다. 게임 엔티티, 컴포넌트 및 시스템을 관리하는 구조적인 접근 방식을 제공하여 성능과 확장성을 높입니다. Flutter와 함께 사용하도록 설계되었으며 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원합니다. 관심사의 분리를 통해 효율적인 데이터 기반 게임 로직을 가능하게 하여 복잡한 게임 아키텍처에 적합합니다. 개발자는 사용자 정의 시스템과 컴포넌트를 통해 기능을 쉽게 확장할 수 있습니다.
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/
A Component is a pretty simple structure and should not contain any logic:
classPositionextendsComponent{
num x, y;
Position(this.x, this.y);
}
Or if you want to use a PooledComponent:
classPositionextendsPooledComponent{
latenum x, y;
Position._();
factoryPosition(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.
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:
classMovementSystemextendsEntityProcessingSystem{
lateMapper<Position> positionMapper;
lateMapper<Velocity> velocityMapper;
MovementSystem() : super(Aspect.forAllOf([Position, Velocity]));
voidinitialize() {
// 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);
}
voidprocessEntity(Entity entity) {
Position position = positionMapper[entity];
Velocity vel = velocityMapper[entity];
position
..x += vel.x * world.delta
..y += vel.y * world.delta;
}
}
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)