add anim and transitions and re-org lua api scripts
This commit is contained in:
parent
a15d0db902
commit
27b6459b9a
24 changed files with 1857 additions and 573 deletions
56
src/pxl8_anim.h
Normal file
56
src/pxl8_anim.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "pxl8_gfx.h"
|
||||
#include "pxl8_types.h"
|
||||
|
||||
typedef struct pxl8_anim_state_machine pxl8_anim_state_machine;
|
||||
|
||||
typedef struct pxl8_anim {
|
||||
u32* frame_ids;
|
||||
u16* frame_durations;
|
||||
u16 frame_count;
|
||||
u16 current_frame;
|
||||
f32 time_accumulator;
|
||||
|
||||
bool loop;
|
||||
bool playing;
|
||||
bool reverse;
|
||||
f32 speed;
|
||||
|
||||
pxl8_anim_state_machine* state_machine;
|
||||
|
||||
void (*on_complete)(void* userdata);
|
||||
void (*on_frame_change)(u16 frame, void* userdata);
|
||||
void* userdata;
|
||||
} pxl8_anim;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
pxl8_anim* pxl8_anim_create(const u32* frame_ids, const u16* frame_durations, u16 frame_count);
|
||||
pxl8_anim* pxl8_anim_create_from_ase(pxl8_gfx* gfx, const char* path);
|
||||
void pxl8_anim_destroy(pxl8_anim* anim);
|
||||
|
||||
pxl8_result pxl8_anim_add_state(pxl8_anim* anim, const char* name, pxl8_anim* state_anim);
|
||||
u16 pxl8_anim_get_current_frame(const pxl8_anim* anim);
|
||||
u32 pxl8_anim_get_current_frame_id(const pxl8_anim* anim);
|
||||
const char* pxl8_anim_get_state(const pxl8_anim* anim);
|
||||
bool pxl8_anim_has_state_machine(const pxl8_anim* anim);
|
||||
bool pxl8_anim_is_complete(const pxl8_anim* anim);
|
||||
bool pxl8_anim_is_playing(const pxl8_anim* anim);
|
||||
void pxl8_anim_pause(pxl8_anim* anim);
|
||||
void pxl8_anim_play(pxl8_anim* anim);
|
||||
void pxl8_anim_render_sprite(const pxl8_anim* anim, pxl8_gfx* gfx, i32 x, i32 y, i32 w, i32 h);
|
||||
void pxl8_anim_reset(pxl8_anim* anim);
|
||||
void pxl8_anim_set_frame(pxl8_anim* anim, u16 frame);
|
||||
void pxl8_anim_set_loop(pxl8_anim* anim, bool loop);
|
||||
void pxl8_anim_set_reverse(pxl8_anim* anim, bool reverse);
|
||||
void pxl8_anim_set_speed(pxl8_anim* anim, f32 speed);
|
||||
pxl8_result pxl8_anim_set_state(pxl8_anim* anim, const char* name);
|
||||
void pxl8_anim_stop(pxl8_anim* anim);
|
||||
void pxl8_anim_update(pxl8_anim* anim, f32 dt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue