Download Tutorial C Files H Files

dg_entity_add_component

This function is used to add a component at an entity.

Usage

void dg_entity_add_component(dg_entity_t *entity, dg_component_t *component);

Example

dg_entity_add_component(entity, dg_cpt_sprite);

Source code

void dg_entity_add_component(dg_entity_t *entity, dg_component_t *component)
{
    if (!entity || !component)
        return;
    dg_arr_add_begin(&(entity->components), component);
}