Exemplo n.º 1
0
void input_beginEvent(InputManager_t *aManager, Input_type_t aType, unsigned char *aCode, vec3_t *aLocation)
{
    int observerCount;
    InputObserver_t **observers = _input_observersForEvent(aManager, aType, aCode, &observerCount);
    _InputEvent_t *existingEvent;
    bool isActive = _input_eventIsActive(aManager, aType, aCode, &existingEvent);

    // Keep the location up to date if the event is already active
    if(isActive && aLocation) existingEvent->location = *aLocation;

    if(!observers || isActive)
        return;

    _InputEvent_t *event = malloc(sizeof(_InputEvent_t));
    event->observerCount = observerCount;
    event->type = aType;
    if(aCode) event->code = *aCode;
    for(int i = 0; i < observerCount; ++i) {
        event->observers[i] = observers[i];
    }
    free(observers);
    if(aLocation != NULL) event->location = *aLocation;
    event->fireCount = 0;
    event->state = kInputState_down;

    llist_pushValue(aManager->activeEvents, event);
}
Exemplo n.º 2
0
void world_addEntity(World_t *aWorld, WorldEntity_t *aEntity)
{
    dynamo_assert(aEntity != aWorld->staticEntity, "You cannot re-add static entity to world");
    cpSpaceAddBody(aWorld->cpSpace, aEntity->cpBody);
    llist_apply(aEntity->shapes, (LinkedListApplier_t)&_addShapeToSpace, aWorld);
    llist_pushValue(aWorld->entities, aEntity);
}
Exemplo n.º 3
0
WorldShape_t *worldEnt_addShape(WorldEntity_t *aEntity, WorldShape_t *aShape)
{
    cpShapeSetBody(aShape->cpShape, aEntity->cpBody);
    if(aEntity == aEntity->world->staticEntity) {
        cpSpaceAddShape(aEntity->world->cpSpace, aShape->cpShape);
    }
    llist_pushValue(aEntity->shapes, aShape);
    return aShape;
}
Exemplo n.º 4
0
void spriteBatch_addSprite(SpriteBatch_t *aBatch, Sprite_t *aSprite)
{
    llist_pushValue(aBatch->sprites, aSprite);
    ++aBatch->spriteCount;
}
Exemplo n.º 5
0
void input_addObserver(InputManager_t *aManager, InputObserver_t *aObserver)
{
    llist_pushValue(aManager->observers, aObserver);
}
Exemplo n.º 6
0
void *autoReleasePool_push(Obj_autoReleasePool_t *aPool, void *aObj)
{
    dynamo_assert(aObj != NULL, "Invalid object");
    llist_pushValue(aPool, aObj);
    return aObj;
}