HTTPS SSH

AtermisCPP is an attempt to port the Artemis framework, written in Java, to C++

The Artemis Java framework

alt text21/25
alt text"Component"
alt text"ComponentMapper"
alt text"ComponentType"
alt text"ComponentTypeManager"
alt text"Entity"
alt text"EntityProcessingSystem"
alt text"EntitySystem"
alt text"SystemBitManager"
alt text"ImmutableBag"
alt text"EntityManager"
alt text"DelayedEntityProcessingSystem"
alt text"DelayedEntitySystem"
alt text"GroupManager"
alt text"IntervalEntityProcessingSystem"
alt text"IntervalEntitySystem"
alt text"Manager"
alt text"SystemManager"
alt text"TagManager"
alt text"utils"
alt text"World"
alt text"Bag"
[ ]"FastMath"
[ ]"Timer"
[ ]"TrigLUT"
[ ]"Utils"


Note:
This project is created with CodeLite.
Working with GCC(mingw) 4.7.0; Enabled experimental c++11 with -std=c++11 (It requires the new standard features)
Documentation and whatnot will be done when every component is in place and working.


example:

Our Movement component ( should probably called VelocityComponent) And our Position component.

class MovementComponent : public artemis::Component
{
public:
    float velocityX;
    float velocityY;

    MovementComponent(float velocityX, float velocityY)
    {
        this->velocityX = velocityX;
        this->velocityY = velocityY;
    };
};

class PositionComponent : public artemis::Component
{

public:
    float posX;
    float posY;
    PositionComponent(float posX, float posY)
    {
        this->posX = posX;
        this->posY = posY;
    };
};

Our system that allows for he positions to be updated

class MovementSystem : public artemis::EntityProcessingSystem
{
private:
    artemis::ComponentMapper<MovementComponent> velocityMapper;
    artemis::ComponentMapper<PositionComponent> positionMapper;

public:
    MovementSystem() {
        setComponentTypes<MovementComponent,PositionComponent>();
    };

    virtual void initialize() {
        velocityMapper.init(*world);
        positionMapper.init(*world);
    };

    virtual void processEntity(artemis::Entity &e) {
        positionMapper.get(e)->posX += velocityMapper.get(e)->velocityX * world->getDelta();
        positionMapper.get(e)->posY += velocityMapper.get(e)->velocityY * world->getDelta();
    };

};

Our test run

int main(int argc, char **argv) {

    artemis::World world;
    artemis::SystemManager * sm = world.getSystemManager();
    MovementSystem * movementsys = (MovementSystem*)sm->setSystem(new MovementSystem());
    artemis::EntityManager * em = world.getEntityManager();

    sm->initializeAll();

    artemis::Entity & player = em->create();



    player.addComponent(new MovementComponent(2,4));
    player.addComponent(new PositionComponent(0,0));
    player.refresh();

    PositionComponent * comp = (PositionComponent*)player.getComponent<PositionComponent>();

    while(true){

        world.loopStart();
        world.setDelta(0.0016f);
        movementsys->process();

        std::cout << "X:"<< comp->posX << std::endl;
        std::cout << "Y:"<< comp->posY << std::endl;
        Sleep(160);
    }

    return 0;
}

Sidar Talei 2012