[gnome-games/gnibbles-clutter-rebased: 97/129] Fixed reversing worm's direction, tweak on animation and some other trivial



commit f97eee04b598ef605c477abc43671f4cc622f5f9
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Tue Aug 11 15:40:33 2009 -0400

    Fixed reversing worm's direction, tweak on animation and some other trivial

 gnibbles/main.c         |    9 +++++++++
 gnibbles/worm-clutter.c |   41 +++++++++++++++++++++++++++--------------
 2 files changed, 36 insertions(+), 14 deletions(-)
---
diff --git a/gnibbles/main.c b/gnibbles/main.c
index c588600..99d1ddf 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -537,6 +537,15 @@ restart_game (gpointer data)
 {
   gnibbles_board_level_new (board, current_level);
   gnibbles_board_level_add_bonus (board, 1);
+  int i;
+  for (i = 0; i < properties->numworms; i++) {
+    clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors);
+    gnibbles_worm_show (worms[i]);
+  }
+
+  for (i = 0; i < properties->human; i++)
+    worms[i]->human = TRUE;
+
   dummy_id = g_timeout_add_seconds (1, (GSourceFunc) new_game_2_cb, NULL);
   restart_id = 0;
   
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 4bd1933..0ec06c2 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -261,7 +261,7 @@ gnibbles_worm_get_tail_direction (GnibblesWorm *worm)
     return -1;
 }
 
-static void
+static gboolean
 gnibbles_worm_inverse (gpointer data)
 {
   GnibblesWorm *worm;
@@ -271,15 +271,6 @@ gnibbles_worm_inverse (gpointer data)
   
   gint old_dir = gnibbles_worm_get_tail_direction (worm);
 
-  if (old_dir == WORMRIGHT)
-    worm->direction = WORMLEFT;
-  else if (old_dir == WORMLEFT)
-    worm->direction = WORMRIGHT;
-  else if (old_dir == WORMUP)
-    worm->direction = WORMDOWN;
-  else if (old_dir == WORMDOWN)
-    worm->direction = WORMUP;
-
   gint tmp;
 
   tmp = worm->xhead;
@@ -289,6 +280,17 @@ gnibbles_worm_inverse (gpointer data)
   worm->yhead = worm->ytail;
   worm->ytail = tmp;
   tmp = worm->yhead;
+
+  if (old_dir == WORMRIGHT)
+    worm->direction = WORMLEFT;
+  else if (old_dir == WORMLEFT)
+    worm->direction = WORMRIGHT;
+  else if (old_dir == WORMUP)
+    worm->direction = WORMDOWN;
+  else if (old_dir == WORMDOWN)
+    worm->direction = WORMUP;
+
+  return FALSE;
 }
 
 static void
@@ -379,6 +381,15 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
 }
 
 static void
+worm_grok_scale_down (ClutterAnimation *animation, ClutterActor *actor)
+{
+  clutter_actor_animate (actor, CLUTTER_EASE_OUT_QUINT, 420,
+                         "scale-x", 1.0, "scale-y", 1.0,
+                         "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                         NULL);
+}
+
+static void
 gnibbles_worm_handle_bonus (GnibblesWorm *worm)
 {
   ClutterActor *actor = NULL;
@@ -388,10 +399,12 @@ gnibbles_worm_handle_bonus (GnibblesWorm *worm)
     gnibbles_worm_grok_bonus (worm);
 
     actor = gnibbles_worm_get_head_actor (worm);
-    clutter_actor_animate (actor, CLUTTER_EASE_OUT_QUINT, 220,
-                           "scale-x", 1.35, "scale-y", 1.35,
-                           "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
-                           NULL);
+    g_signal_connect_after (
+      clutter_actor_animate (actor, CLUTTER_EASE_OUT_QUINT, 420,
+                            "scale-x", 1.45, "scale-y", 1.45,
+                            "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                            NULL),
+      "completed", G_CALLBACK (worm_grok_scale_down), actor);
 
     if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
 	      !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]