6 n__anim_8h
gullradriel edited this page 2026-10-09 00:55:18 +02:00

include/nilorea/n_anim.h

Animations graphics and animations parameters. More...

Structures

Name
struct ANIM_LIB
structure of a library of gfxs
struct ANIM_GFX
struct of an animation
struct ANIM_FRAME
struct of the properties of a frame in an animation
struct ANIM_DATA
animation properties

Detailed Description

Animations graphics and animations parameters.

Author: Castagnier Mickael aka Gull Ra Driel

Version: 1.0

Date: 30/12/2016

Source code

/*
 * Nilorea Library
 * Copyright (C) 2005-2026 Castagnier Mickael
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef __N_ANIM_HEADER
#define __N_ANIM_HEADER

#ifdef __cplusplus
extern "C" {
#endif

#include "n_common.h"
#include "n_log.h"
#include "n_str.h"
#include "allegro5/allegro.h"


typedef struct ANIM_FRAME {
    int x,
        y;
    unsigned int duration;
} ANIM_FRAME;

typedef struct ANIM_GFX {
    ANIM_FRAME* frames;
    ALLEGRO_BITMAP* bmp;

    unsigned int type,
        w,
        h,
        nb_frames;
} ANIM_GFX;

typedef struct ANIM_LIB {
    ANIM_GFX** gfxs;

    unsigned int nb_max_gfxs;

    char* name;
} ANIM_LIB;

typedef struct ANIM_DATA {
    unsigned int id,
        x,
        y,
        frame,
        elapsed;

    ANIM_LIB* lib;
} ANIM_DATA;

ANIM_LIB* create_anim_library(const char* name, unsigned int size);
int delete_bmp_from_lib(ANIM_LIB* lib, unsigned int id);
int add_bmp_to_lib(ANIM_LIB* lib, unsigned int pos, char* file, char* resfile);
int update_anim(ANIM_DATA* data, unsigned int delta_t);
int draw_anim(ANIM_DATA* data, int x, int y);
int destroy_anim_lib(ANIM_LIB** lib);


#ifdef __cplusplus
}
#endif

#endif  // header guard