summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-10-16 22:19:48 -0700
committerBenjamin Otte <otte@redhat.com>2011-10-16 22:32:55 -0700
commit42756d85262d61c2330917732a4bd6683c80df80 (patch)
tree3f7f5efda7c0724cbdbce8e84c07f987161d1fe9
parentce994e311f4573f82ccdd83ddf5ccf1a217bb46a (diff)
animation: Allow empty animation frames
In that case, the current image will be kept. I don't like the current approach of using maybe values, but it works. Tis fixes bomber animations being too fast.
-rw-r--r--games/bomber/bomber.resources67
-rw-r--r--libgame/game-animation-resource.c31
2 files changed, 82 insertions, 16 deletions
diff --git a/games/bomber/bomber.resources b/games/bomber/bomber.resources
index df9075a..ac0d0ef 100644
--- a/games/bomber/bomber.resources
+++ b/games/bomber/bomber.resources
@@ -4,22 +4,39 @@
< ("GameAnimationResource",
-0.16666666666, 0.0, 1.3333333333, 1.0,
[ < ("GameFileResource", "bomb00.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb01.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb02.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb03.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb04.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb05.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb06.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb07.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb08.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb09.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb10.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb11.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb12.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb13.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb14.png") >,
+ nothing, nothing, nothing, nothing, nothing, nothing, nothing,
< ("GameFileResource", "bomb15.png") >,
- < ("GameFileResource", "bomb16.png") >
+ nothing, nothing, nothing, nothing, nothing, nothing,
+ < ("GameFileResource", "bomb16.png") >,
+ nothing
]
) >
,
@@ -27,9 +44,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-left0.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-left1.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-left2.png") >,
- < ("GameFileResource", "bomber-left3.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-left3.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -37,9 +58,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-left0-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-left1-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-left2-overlay.png") >,
- < ("GameFileResource", "bomber-left3-overlay.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-left3-overlay.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -47,9 +72,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-right0.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-right1.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-right2.png") >,
- < ("GameFileResource", "bomber-right3.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-right3.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -57,9 +86,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-right0-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-right1-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-right2-overlay.png") >,
- < ("GameFileResource", "bomber-right3-overlay.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-right3-overlay.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -67,9 +100,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-up0.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-up1.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-up2.png") >,
- < ("GameFileResource", "bomber-up3.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-up3.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -77,9 +114,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-up0-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-up1-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-up2-overlay.png") >,
- < ("GameFileResource", "bomber-up3-overlay.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-up3-overlay.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -87,9 +128,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-down0.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-down1.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-down2.png") >,
- < ("GameFileResource", "bomber-down3.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-down3.png") >,
+ nothing, nothing, nothing
]
) >
,
@@ -97,9 +142,13 @@
< ( "GameAnimationResource",
-0.3, -0.9, 1.6, 1.8,
[ < ("GameFileResource", "bomber-down0-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-down1-overlay.png") >,
+ nothing, nothing, nothing,
< ("GameFileResource", "bomber-down2-overlay.png") >,
- < ("GameFileResource", "bomber-down3-overlay.png") >
+ nothing, nothing, nothing,
+ < ("GameFileResource", "bomber-down3-overlay.png") >,
+ nothing, nothing, nothing
]
) >
,
diff --git a/libgame/game-animation-resource.c b/libgame/game-animation-resource.c
index 99f0fe4..cf1c03c 100644
--- a/libgame/game-animation-resource.c
+++ b/libgame/game-animation-resource.c
@@ -103,17 +103,22 @@ game_animation_resource_load (GameResource *res, GVariantIter *iter)
!g_variant_iter_next (iter, "d", &resource->size.y1) ||
!g_variant_iter_next (iter, "d", &resource->size.x2) ||
!g_variant_iter_next (iter, "d", &resource->size.y2) ||
- !g_variant_iter_next (iter, "av", &array))
+ !g_variant_iter_next (iter, "amv", &array))
return FALSE;
resource->size.x2 += resource->size.x1;
resource->size.y2 += resource->size.y1;
- while (g_variant_iter_loop (array, "v", &variant))
+ while (g_variant_iter_loop (array, "mv", &variant))
{
- data = GAME_DATA_RESOURCE (game_resource_load (GAME_OBJECT (resource)->game, variant));
- game_animation_resource_add_frame (resource, data);
- g_object_unref (data);
+ if (variant)
+ {
+ data = GAME_DATA_RESOURCE (game_resource_load (GAME_OBJECT (resource)->game, variant));
+ game_animation_resource_add_frame (resource, data);
+ g_object_unref (data);
+ }
+ else
+ game_animation_resource_add_frame (resource, NULL);
}
g_variant_iter_free (array);
@@ -237,10 +242,22 @@ void
game_animation_resource_add_frame (GameAnimationResource *resource,
GameDataResource * data)
{
+ cairo_surface_t *surface;
+
g_return_if_fail (GAME_IS_ANIMATION_RESOURCE (resource));
- g_return_if_fail (GAME_IS_DATA_RESOURCE (data));
+ g_return_if_fail (data == NULL || GAME_IS_DATA_RESOURCE (data));
+
+ if (data == NULL)
+ {
+ g_return_if_fail (resource->frames->len > 0);
+
+ data = g_ptr_array_index (resource->frames, resource->frames->len - 1);
+ surface = cairo_surface_reference (g_ptr_array_index (resource->surfaces, resource->surfaces->len - 1));
+ }
+ else
+ surface = game_animation_resource_load_surface (data);
g_ptr_array_add (resource->frames, g_object_ref (data));
- g_ptr_array_add (resource->surfaces, game_animation_resource_load_surface (data));
+ g_ptr_array_add (resource->surfaces, surface);
}