RogueLife/src/anim.h

40 lines
918 B
C
Raw Normal View History

2021-06-09 20:47:39 +02:00
//---
// anim: Renderer's animations
//
// Animations in this engine are simply linked variants of sprites. Animated
// images change over time, moving from frame to frame, and that's it.
//---
#pragma once
#include <stdint.h>
#include "fixed.h"
#include <gint/display.h>
typedef struct anim_frame {
/* Sheet */
bopti_image_t const *sheet;
/* Box for the frame within the sheet */
uint8_t x, y, w, h;
/* Position of center for this frame */
uint8_t cx, cy;
/* Duration of the frame (ms) */
uint16_t duration;
/* Next frame */
struct anim_frame *next;
} anim_frame_t;
typedef struct {
/* Current frame */
anim_frame_t const *frame;
/* Time elapsed */
uint16_t elapsed;
} anim_state_t;
/* Render a frame at the center position (x,y). */
void anim_frame_render(int x, int y, anim_frame_t const *frame);
/* Update an animation to next frame */
void anim_state_update(anim_state_t *state, fixed_t dt);