mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
character: fix stopping of non-repeating reversed spritesheets
This commit is contained in:
parent
1d6dc5e0d0
commit
11267cd3b1
2 changed files with 19 additions and 1 deletions
|
@ -531,7 +531,7 @@ SYMBOL_EXPORT void AnimateCharacter(struct Game* game, struct Character* charact
|
|||
} else {
|
||||
if (character->repeats == 0) {
|
||||
if (character->reversed) {
|
||||
character->pos = 1;
|
||||
character->pos = 0;
|
||||
} else {
|
||||
character->pos = character->spritesheet->frame_count - 1;
|
||||
}
|
||||
|
|
|
@ -68,9 +68,27 @@ static void character_spritesheet_stops(void** state) {
|
|||
assert_int_equal(character->pos, 2);
|
||||
}
|
||||
|
||||
static void character_spritesheet_reversed_stops(void** state) {
|
||||
struct Game* game = *state;
|
||||
struct Character* character = CreateCharacter(game, "test");
|
||||
RegisterSpritesheet(game, character, "animation");
|
||||
SelectSpritesheet(game, character, "-animation");
|
||||
|
||||
assert_int_equal(character->pos, 2);
|
||||
AnimateCharacter(game, character, 0.1, 1.0);
|
||||
assert_int_equal(character->pos, 1);
|
||||
AnimateCharacter(game, character, 0.1, 1.0);
|
||||
assert_int_equal(character->pos, 0);
|
||||
AnimateCharacter(game, character, 0.1, 1.0);
|
||||
assert_int_equal(character->pos, 0);
|
||||
AnimateCharacter(game, character, 0.1, 1.0);
|
||||
assert_int_equal(character->pos, 0);
|
||||
}
|
||||
|
||||
int test_character(void) {
|
||||
const struct CMUnitTest character_tests[] = {
|
||||
cmocka_unit_test(character_spritesheet_stops),
|
||||
cmocka_unit_test(character_spritesheet_reversed_stops),
|
||||
};
|
||||
return cmocka_run_group_tests(character_tests, character_setup, character_teardown);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue