mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
character: GetCharacterTransform: Set pivot point before flipping
BREAKING CHANGE. This way the pivot point stays in the same position regardless of flips.
This commit is contained in:
parent
ffdebba9ec
commit
ac83b72899
1 changed files with 4 additions and 8 deletions
|
@ -738,16 +738,12 @@ SYMBOL_EXPORT ALLEGRO_TRANSFORM GetCharacterTransform(struct Game* game, struct
|
|||
int w = character->spritesheet->width, h = character->spritesheet->height;
|
||||
al_identity_transform(&transform);
|
||||
|
||||
al_translate_transform(&transform, -w / 2.0, -h / 2.0);
|
||||
al_scale_transform(&transform, ((character->flipX ^ character->spritesheet->flipX ^ character->frame->flipX) ? -1 : 1), ((character->flipY ^ character->spritesheet->flipY ^ character->frame->flipY) ? -1 : 1)); // flipping; FIXME: should it be here or later?
|
||||
al_translate_transform(&transform, w / 2.0, h / 2.0);
|
||||
|
||||
al_translate_transform(&transform, -w * character->spritesheet->pivotX, -h * character->spritesheet->pivotY); // pivot
|
||||
al_translate_transform(&transform, -w * character->spritesheet->pivotX, -h * character->spritesheet->pivotY);
|
||||
al_scale_transform(&transform, ((character->flipX ^ character->spritesheet->flipX ^ character->frame->flipX) ? -1 : 1), ((character->flipY ^ character->spritesheet->flipY ^ character->frame->flipY) ? -1 : 1));
|
||||
al_scale_transform(&transform, character->scaleX, character->scaleY);
|
||||
al_rotate_transform(&transform, character->angle);
|
||||
|
||||
al_translate_transform(&transform, character->spritesheet->offsetX, character->spritesheet->offsetY); // spritesheet offset
|
||||
al_translate_transform(&transform, GetCharacterX(game, character), GetCharacterY(game, character)); // position
|
||||
al_translate_transform(&transform, character->spritesheet->offsetX, character->spritesheet->offsetY);
|
||||
al_translate_transform(&transform, GetCharacterX(game, character), GetCharacterY(game, character));
|
||||
|
||||
if (character->parent) {
|
||||
ALLEGRO_TRANSFORM parent = GetCharacterTransform(game, character->parent);
|
||||
|
|
Loading…
Reference in a new issue