mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
character: add ability to specify per-frame color tint
This commit is contained in:
parent
093a808dc2
commit
341aa1d823
2 changed files with 14 additions and 1 deletions
|
@ -270,6 +270,13 @@ SYMBOL_EXPORT void RegisterSpritesheet(struct Game* game, struct Character* char
|
|||
s->frames[i].flipX = strtolnull(al_get_config_value(config, framename, "flipX"), 0);
|
||||
s->frames[i].flipY = strtolnull(al_get_config_value(config, framename, "flipY"), 0);
|
||||
|
||||
double r, g, b, a;
|
||||
r = strtodnull(al_get_config_value(config, framename, "r"), 1);
|
||||
g = strtodnull(al_get_config_value(config, framename, "g"), 1);
|
||||
b = strtodnull(al_get_config_value(config, framename, "b"), 1);
|
||||
a = strtodnull(al_get_config_value(config, framename, "a"), 1);
|
||||
s->frames[i].tint = al_premul_rgba_f(r, g, b, a);
|
||||
|
||||
s->frames[i].file = NULL;
|
||||
const char* file = al_get_config_value(config, framename, "file");
|
||||
if (file) {
|
||||
|
@ -529,7 +536,12 @@ SYMBOL_EXPORT void DrawCharacter(struct Game* game, struct Character* character)
|
|||
al_compose_transform(&transform, ¤t);
|
||||
al_use_transform(&transform);
|
||||
|
||||
al_draw_tinted_bitmap(character->frame->bitmap, character->tint, 0, 0, 0);
|
||||
float r, g, b, a, r2, g2, b2, a2;
|
||||
al_unmap_rgba_f(character->tint, &r, &g, &b, &a);
|
||||
al_unmap_rgba_f(character->frame->tint, &r2, &g2, &b2, &a2);
|
||||
ALLEGRO_COLOR tint = al_map_rgba_f(r * r2, g * g2, b * b2, a * a2);
|
||||
|
||||
al_draw_tinted_bitmap(character->frame->bitmap, tint, 0, 0, 0);
|
||||
|
||||
/* al_hold_bitmap_drawing(false);
|
||||
al_draw_filled_rectangle(character->spritesheet->width * character->spritesheet->pivotX - 5,
|
||||
|
|
|
@ -30,6 +30,7 @@ struct SpritesheetFrame {
|
|||
char* filepath;
|
||||
ALLEGRO_BITMAP* bitmap;
|
||||
double duration;
|
||||
ALLEGRO_COLOR tint;
|
||||
int row;
|
||||
int col;
|
||||
int x;
|
||||
|
|
Loading…
Add table
Reference in a new issue