artemisd ~master
A D port of Artemis Entity System Framework
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
ArtemisD
A D port of Artemis Entity System Framework
Artemis is a high performance Entity System framework for games.
Manual: http://gamadu.com/artemis/manual.html
Tutorial: http://gamadu.com/artemis/tutorial.html
##License New BSD license
##Example
import std.stdio;
import artemisd.all;
final class Position : Component
{
mixin TypeDecl;
float x;
float y;
this(float x, float y)
{
this.x = x;
this.y = y;
}
}
final class Velocity : Component
{
mixin TypeDecl;
float x;
float y;
this(float x, float y)
{
this.x = x;
this.y = y;
}
}
final class Renderer : Component
{
mixin TypeDecl;
}
final class MovementSystem : EntityProcessingSystem
{
mixin TypeDecl;
this()
{
super(Aspect.getAspectForAll!(Position,Velocity));
}
override void process(Entity e)
{
Position pos = e.getComponent!Position;
Velocity vel = e.getComponent!Velocity;
Renderer rend = e.getComponent!Renderer;
assert(pos !is null);
assert(vel !is null);
assert(rend is null);
pos.x += vel.x * world.getDelta();
pos.y += vel.y * world.getDelta();
writeln(e, " move to (", pos.x, ",", pos.y, ")");
}
}
final class RenderSystem : EntityProcessingSystem
{
mixin TypeDecl;
this()
{
super(Aspect.getAspectForAll!(Position, Renderer));
}
override void process(Entity e)
{
Renderer rend = e.getComponent!Renderer;
Position pos = e.getComponent!Position;
assert(pos !is null);
assert(rend !is null);
writeln(e, " rendered at (", pos.x, ",", pos.y, ")");
}
}
void main(string[] argv)
{
World world = new World();
world.setSystem(new MovementSystem);
world.setSystem(new RenderSystem);
world.initialize();
Entity e = world.createEntity();
e.addComponent(new Position(0,0));
e.addComponent(new Velocity(10,0));
e.addToWorld();
Entity e1 = world.createEntity();
e1.addComponent(new Position(0,0));
e1.addComponent(new Renderer);
e1.addToWorld();
import core.thread;
while(true)
{
world.setDelta(1/60.0f);
world.process();
Thread.sleep(1000.msecs);
}
}
- Registered by Elvis Zhou
- ~master released 9 years ago
- elvisxzhou/artemisd
- github.com/elvisxzhou/artemisd
- BSD 3-Clause
- Copyright (c) 2013, Elvis Zhou
- Authors:
- Dependencies:
- none
- Versions:
-
~master 2015-Jul-27 ~dev 2013-Oct-07 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
342 downloads total
-
- Score:
- 1.7
- Short URL:
- artemisd.dub.pm