123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #ifndef DD_ANIMATION_H
- #define DD_ANIMATION_H
- /* Used for creating animations
- * Counts from 0 to given value
- * Can check if animation is increasing or decreasing
- * `update()` moves animation until it ends (reach max or 0)
- returns true if updated, false otherwise
- * `interpolate()` takes a float (usually a distance)
- and calculates the interpolated value from 0 to that float
- */
- /* so far, 255 values were enough for an animation, I don't know
- * if I'll change it later on
- */
- typedef unsigned char anim_size;
- /* Animation struct */
- struct dd_animation {
- /* Counters */
- anim_size counter, max;
- /* Boolean */
- char positive;
- };
- /* initializes an animation struct */
- void dd_animation_init(struct dd_animation *a, anim_size max_value);
- /* updates animation */
- int dd_animation_update(struct dd_animation *a);
- /* Start animation
- * the `0` version starts from 0 and moves positively
- * the `max` version starts from max and moves negatively
- * flip just changes the direction of the update
- */
- void dd_animation_start0(struct dd_animation *a);
- void dd_animation_startmax(struct dd_animation *a);
- void dd_animation_flip(struct dd_animation *a);
- /* Get an interpolated value, from 0 to value
- * taken from animation's size
- */
- float dd_animation_interpolate(struct dd_animation *a, float value);
- /* issers */
- int dd_animation_isrunning(struct dd_animation *a);
- #endif
|