Skip to content

Commit

Permalink
Attempts to solve task SuperTux#1111 (SuperTux#1275)
Browse files Browse the repository at this point in the history
* Attempts to solve task SuperTux#1111

* Fixes a bad value conversion
  • Loading branch information
LiquidityC authored and tobbi committed Dec 16, 2019
1 parent 4281694 commit 60cc0e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ build.*/
**/CMakeFiles/
**/CMakeCache.txt
supertux2

# Tags file
tags

# Windows build files
Debug/
Release/
Expand Down
3 changes: 0 additions & 3 deletions data/images/creatures/snowball/snowball.sprite
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
)
(action
(name "right")
(hitbox 3 4 32 32)
(mirror-action "left")
)
(action
Expand All @@ -19,7 +18,6 @@
)
(action
(name "squished-right")
(hitbox 1 -19 31.8 31.8)
(mirror-action "squished-left")
)
(action
Expand All @@ -31,7 +29,6 @@
"sport-melting-3.png"))
(action
(name "melting-right")
(hitbox 3 4 32 32)
(mirror-action "melting-left"))
(action
(name "ground-melting-left")
Expand Down
21 changes: 19 additions & 2 deletions src/sprite/sprite_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,25 @@ SpriteData::parse_action(const ReaderMapping& mapping)
max_h = std::max(max_h, static_cast<float>(surface->get_height()));
action->surfaces.push_back(surface);
}
if (action->hitbox_w < 1) action->hitbox_w = max_w - action->x_offset;
if (action->hitbox_h < 1) action->hitbox_h = max_h - action->y_offset;

if (action->hitbox_w < 1 && action->hitbox_h < 1)
{
action->hitbox_w = act_tmp->hitbox_w;
action->hitbox_h = act_tmp->hitbox_h;
action->x_offset = act_tmp->x_offset;
action->y_offset = act_tmp->y_offset;
}

if (!action->has_custom_loops && act_tmp->has_custom_loops)
{
action->has_custom_loops = act_tmp->has_custom_loops;
action->loops = act_tmp->loops;
}

if (action->fps == 0)
{
action->fps = act_tmp->fps;
}
}
} else if (mapping.get("clone-action", clone_action)) {
const auto* act_tmp = get_action(clone_action);
Expand Down

0 comments on commit 60cc0e0

Please sign in to comment.