[gnome-games/gnibbles-clutter] Added an animation when a game end
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/gnibbles-clutter] Added an animation when a game end
- Date: Sat, 22 Aug 2009 16:21:32 +0000 (UTC)
commit a3920cc354ecd428518f30c8a8fee9453e0842fb
Author: Guillaume Beland <guillaume beland gmail com>
Date: Sat Aug 22 12:19:13 2009 -0400
Added an animation when a game end
gnibbles/gnibbles.c | 9 ------
gnibbles/gnibbles.h | 1 -
gnibbles/main.c | 80 +++++++++++++++++++++++++++-----------------------
3 files changed, 43 insertions(+), 47 deletions(-)
---
diff --git a/gnibbles/gnibbles.c b/gnibbles/gnibbles.c
index 5d0f32c..a05c17b 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -363,15 +363,6 @@ gnibbles_keypress_worms (guint keyval)
}
void
-gnibbles_undraw_worms (gint data)
-{
- gint i;
-
- for (i = 0; i < properties->numworms; i++)
- gnibbles_worm_reduce_tail (worms[i], data);
-}
-
-void
gnibbles_show_scores (GtkWidget * window, gint pos)
{
static GtkWidget *scoresdialog = NULL;
diff --git a/gnibbles/gnibbles.h b/gnibbles/gnibbles.h
index 0fb41b3..3d2dc84 100644
--- a/gnibbles/gnibbles.h
+++ b/gnibbles/gnibbles.h
@@ -65,7 +65,6 @@ void gnibbles_add_bonus (gint regular);
gint gnibbles_move_worms (void);
gint gnibbles_get_winner (void);
gboolean gnibbles_keypress_worms (guint keyval);
-void gnibbles_undraw_worms (gint data);
void gnibbles_show_scores (GtkWidget * window, gint pos);
void gnibbles_log_score (GtkWidget * window);
void gnibbles_add_spec_bonus (gint t_x, gint t_y,
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 5b6821f..6fe4fbe 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -98,7 +98,6 @@ extern GnibblesBoni *boni;
gint main_id = 0;
gint dummy_id = 0;
gint keyboard_id = 0;
-gint erase_id = 0;
gint add_bonus_id = 0;
gint restart_id = 0;
@@ -189,7 +188,7 @@ show_cursor (void)
gint
game_running (void)
{
- return (main_id || erase_id || dummy_id || restart_id || paused);
+ return (main_id || dummy_id || restart_id || paused);
}
static void
@@ -208,8 +207,6 @@ delete_cb (GtkWidget * widget, gpointer data)
{
if (main_id)
g_source_remove (main_id);
- if (erase_id)
- g_source_remove (erase_id);
if (dummy_id)
g_source_remove (dummy_id);
if (restart_id)
@@ -394,11 +391,6 @@ new_game (void)
gtk_action_set_visible (resume_action, paused);
gtk_action_set_visible (player_list_action, ggz_network_mode);
- if (erase_id) {
- g_source_remove (erase_id);
- erase_id = 0;
- }
-
if (restart_id) {
g_source_remove (restart_id);
restart_id = 0;
@@ -432,7 +424,7 @@ pause_game_cb (GtkAction * action, gpointer data)
paused = 0;
dummy_id = g_timeout_add (500, (GSourceFunc) new_game_2_cb, NULL);
} else {
- if (main_id || erase_id || restart_id || dummy_id) {
+ if (main_id || restart_id || dummy_id) {
paused = 1;
if (main_id) {
g_source_remove (main_id);
@@ -481,11 +473,6 @@ end_game (gboolean show_splash)
add_bonus_id = 0;
}
- if (erase_id) {
- g_source_remove (erase_id);
- erase_id = 0;
- }
-
if (dummy_id) {
g_source_remove (dummy_id);
dummy_id = 0;
@@ -555,23 +542,45 @@ restart_game (gpointer data)
return FALSE;
}
-static gboolean
-erase_worms_cb (gpointer datap)
+static void
+end_game_anim_cb (ClutterAnimation *animation, ClutterActor *actor)
{
- gint data = GPOINTER_TO_INT (datap);
+ if (!restart_id)
+ end_game (TRUE);
+}
- if (data == 0) {
- erase_id = 0;
- if (!restart_id)
- end_game (TRUE);
- } else {
- gnibbles_undraw_worms (ERASESIZE - data);
- erase_id = g_timeout_add (ERASETIME / ERASESIZE,
- (GSourceFunc) erase_worms_cb,
- GINT_TO_POINTER (data - 1));
+static void
+animate_end_game (void)
+{
+ int i;
+ for (i = 0; i < properties->numworms; i++) {
+ clutter_actor_animate (worms[i]->actors, CLUTTER_EASE_IN_QUAD, 500,
+ "opacity", 0,
+ "scale-x", 0.4, "scale-y", 0.4,
+ "fixed::scale-center-x",
+ (gfloat) worms[i]->xhead * properties->tilesize,
+ "fixed::scale-center-y",
+ (gfloat) worms[i]->yhead * properties->tilesize,
+ NULL);
}
- return FALSE;
+ for ( i = 0; i < boni->numbonuses; i++) {
+ clutter_actor_animate (boni->bonuses[i]->actor, CLUTTER_EASE_IN_QUAD, 500,
+ "opacity", 0,
+ "scale-x", 0.4, "scale-y", 0.4,
+ "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+ NULL);
+
+ }
+
+ g_signal_connect_after (
+ clutter_actor_animate (board->level, CLUTTER_EASE_IN_QUAD, 700,
+ "scale-x", 0.4, "scale-y", 0.4,
+ "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+ "opacity", 0,
+ NULL),
+ "completed", G_CALLBACK (end_game_anim_cb), NULL);
+
}
gboolean
@@ -610,9 +619,7 @@ main_loop (gpointer data)
g_source_remove (add_bonus_id);
add_bonus_id = 0;
- erase_id = g_timeout_add_seconds (3,
- (GSourceFunc) erase_worms_cb,
- (gpointer) ERASESIZE);
+
gnibbles_log_score (window);
return FALSE;
@@ -629,9 +636,9 @@ main_loop (gpointer data)
g_source_remove (add_bonus_id);
add_bonus_id = 0;
- erase_id = g_timeout_add_seconds (3,
- (GSourceFunc) erase_worms_cb,
- (gpointer) ERASESIZE);
+
+ animate_end_game ();
+
gnibbles_log_score (window);
return FALSE;
}
@@ -657,9 +664,8 @@ main_loop (gpointer data)
main_id = 0;
}
add_bonus_id = 0;
- erase_id = g_timeout_add (ERASETIME / ERASESIZE,
- (GSourceFunc) erase_worms_cb,
- (gpointer) ERASESIZE);
+ animate_end_game ();
+
restart_id = g_timeout_add_seconds (1, (GSourceFunc) restart_game, NULL);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]