40 lines
918 B
C
40 lines
918 B
C
|
//---
|
||
|
// 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);
|