[gnome-games/gnibbles-clutter] New animation on bonus



commit 7a238231ae708d2479bd83d85419b5ffbc160e3d
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Tue Aug 4 20:34:52 2009 -0400

    New animation on bonus
    
    Rotating was nice but it didn't fit the game. Bonus now slowly scale in and out,
    more subttile and a lot nicer

 gnibbles/bonus.c        |   39 +++++++++++++++++++++++++++++++++------
 gnibbles/worm-clutter.c |   12 ++++++------
 2 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/gnibbles/bonus.c b/gnibbles/bonus.c
index 9c079f1..3a3eaff 100644
--- a/gnibbles/bonus.c
+++ b/gnibbles/bonus.c
@@ -38,21 +38,48 @@ extern GnibblesProperties *properties;
 extern GnibblesBoard *board;
 extern ClutterActor *stage;
 
+static void animate_bonus1 (ClutterAnimation *animation, ClutterActor *actor);
+static void animate_bonus2 (ClutterAnimation *animation, ClutterActor *actor);
+
 static void
-animate_bonus (ClutterAnimation *animation, ClutterActor *actor)
+animate_bonus_rotate (ClutterAnimation *animation, ClutterActor *actor)
 {
   ClutterVertex center;
   ClutterAnimation *anim;
 
   center = (ClutterVertex){(gfloat)properties->tilesize, 0, 0};
   anim = clutter_actor_animate (actor, CLUTTER_LINEAR, 2000,
-                         "rotation-angle-y", 360.f,
-                         "fixed::rotation-center-y", &center,
-                         NULL);
+                                "rotation-angle-y", 360.f,
+                                "fixed::rotation-center-y", &center,
+                                NULL);
   clutter_animation_set_loop (anim, TRUE);
-  
 }
 
+static void
+animate_bonus1 (ClutterAnimation *animation, ClutterActor *actor)
+{
+  g_signal_connect_after (
+    clutter_actor_animate (actor, CLUTTER_LINEAR, 1100,
+                                "scale-x", 1.2, "scale-y", 1.2,
+                                "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                                NULL),
+      "completed", G_CALLBACK (animate_bonus2), actor);
+
+}
+
+static void
+animate_bonus2 (ClutterAnimation *animation, ClutterActor *actor)
+{
+  g_signal_connect_after (
+    clutter_actor_animate (actor, CLUTTER_LINEAR, 1100,
+                                "scale-x", 0.9, "scale-y", 0.9,
+                                "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                                NULL),
+      "completed", G_CALLBACK (animate_bonus1), actor);
+
+}
+
+
 GnibblesBonus *
 gnibbles_bonus_new (gint t_x, gint t_y, gint t_type,
 		    gint t_fake, gint t_countdown)
@@ -92,7 +119,7 @@ gnibbles_bonus_draw (GnibblesBonus *bonus)
     clutter_actor_animate (bonus->actor, CLUTTER_EASE_IN_QUAD, 500,
                          "opacity", 0xff,
                           NULL),
-    "completed", G_CALLBACK (animate_bonus), bonus->actor);
+    "completed", G_CALLBACK (animate_bonus1), bonus->actor);
 }
 
 void
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 3b09223..e576d02 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -385,7 +385,7 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
     }
     board->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
   }
-
+/*
   FILE *fo;
   fo = fopen ("output.txt", "w" );
   for (i = 0; i < BOARDHEIGHT; i++) {
@@ -398,7 +398,7 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
     fprintf (fo, "\n");
   }
   fclose (fo);
-
+*/
 }
 
 static void *
@@ -484,10 +484,11 @@ gnibbles_worm_move_tail_pointer (GnibblesWorm *worm)
 static void
 gnibbles_worm_handle_bonus (GnibblesWorm *worm)
 {
+  ClutterActor *actor = NULL;
   if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
     (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
-   gnibbles_worm_grok_bonus (worm);
- 
+    gnibbles_worm_grok_bonus (worm);
+
     if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
 	      !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
 
@@ -622,8 +623,8 @@ gnibbles_worm_remove_actor (GnibblesWorm *worm)
   g_return_if_fail (worm->list);
 
   ClutterActor *tmp = gnibbles_worm_get_tail_actor (worm);
+  
   worm->list = g_list_delete_link (worm->list, g_list_last (worm->list));
-
   clutter_container_remove_actor (CLUTTER_CONTAINER (worm->actors), tmp);
 }
 
@@ -965,7 +966,6 @@ gnibbles_worm_shrink (GnibblesWorm *worm, gint shrinksize)
 
   nbr_actor = g_list_length (worm->list);
 
-  //TODO: add animation
   for (i = 0; i < nbr_actor; i++) {
     tmp = CLUTTER_ACTOR (g_list_last (worm->list)->data); 
     clutter_actor_get_size (CLUTTER_ACTOR (tmp), &w, &h);



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