Download Tutorial C Files H Files

dg_spritesheet_create

This function is used to initialize the spritesheet.

Usage

dg_spritesheet_t *dg_spritesheet_create(char *filepath, int x, int y);

Example

dg_spritesheet_t *sheet = dg_spritesheet_create("res/bat.png", 32, 32);

Source code

dg_spritesheet_t *dg_spritesheet_create(char *filepath, int x, int y)
{
    dg_spritesheet_t *spritesheet = malloc(sizeof(dg_spritesheet_t));
    sfImage *file = sfImage_createFromFile(filepath);
    sfTexture *sheet = sfTexture_createFromImage(file, 0);

    if (!spritesheet)
        return 0;
    spritesheet->sheet = sheet;
    spritesheet->x = x;
    spritesheet->y = y;
    return spritesheet;
}