[gnome-games] New effect on worms when eating a bonus, still need polishing



commit 0fdc9355d2d209279a480db58166b0d1e44e5b0a
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Sat Aug 8 14:16:46 2009 -0400

    New effect on worms when eating a bonus, still need polishing

 gnibbles/bonus.c        |   16 +++++-----
 gnibbles/worm-clutter.c |   71 ++++++++++++++++++++++++-----------------------
 2 files changed, 44 insertions(+), 43 deletions(-)
---
diff --git a/gnibbles/bonus.c b/gnibbles/bonus.c
index 2069007..7e23b42 100644
--- a/gnibbles/bonus.c
+++ b/gnibbles/bonus.c
@@ -60,10 +60,10 @@ animate_bonus1 (ClutterAnimation *animation, ClutterActor *actor)
 {
   g_signal_connect_after (
     clutter_actor_animate (actor, CLUTTER_LINEAR, 1100,
-                                "scale-x", 1.22, "scale-y", 1.22,
-                                "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
-                                "opacity", 0xDC,
-                                NULL),
+                           "scale-x", 1.22, "scale-y", 1.22,
+                           "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                           "opacity", 0xDC,
+                           NULL),
       "completed", G_CALLBACK (animate_bonus2), actor);
 
 }
@@ -73,10 +73,10 @@ 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,
-                                "opacity", 0xFF,
-                                NULL),
+                           "scale-x", 0.9, "scale-y", 0.9,
+                           "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                           "opacity", 0xFF,
+                           NULL),
       "completed", G_CALLBACK (animate_bonus1), actor);
 
 }
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 51ab876..6344728 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -375,7 +375,39 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
     fprintf (fo, "\n");
   }
   fclose (fo);
-  */
+  */ 
+}
+
+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);
+    actor = gnibbles_worm_get_head_actor (worm);
+    clutter_actor_animate (actor, CLUTTER_LINEAR, 300,
+                           "scale-x", 1.45, "scale-y", 1.45,
+                           "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
+                           NULL);
+
+    if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
+	      !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
+      
+      gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
+      
+      if (boni->numleft != 0)
+	      gnibbles_board_level_add_bonus (board, 1);
+
+    } else
+        gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
+  }
+
+  if (board->walls[worm->xhead][worm->yhead] == WARPLETTER) {
+    gnibbles_warpmanager_worm_change_pos (warpmanager, worm);
+    games_sound_play ("teleport");
+  }
 }
 
 static void *
@@ -417,14 +449,14 @@ gnibbles_worm_move_head_pointer (GnibblesWorm *worm)
   }
 
   if (worm->xhead <= 0)
-    worm->xhead = BOARDWIDTH;
+    worm->xhead = BOARDWIDTH - 1;
   if (worm->yhead <= 0)
-    worm->yhead = BOARDHEIGHT;
+    worm->yhead = BOARDHEIGHT - 1;
   if (worm->xhead >= BOARDWIDTH)
     worm->xhead = 0;
   if (worm->yhead >= BOARDHEIGHT) 
     worm->yhead = 0;
-
+  gnibbles_worm_handle_bonus (worm);
   gnibbles_worm_add_actor (worm);
 }
 
@@ -453,35 +485,6 @@ gnibbles_worm_move_tail_pointer (GnibblesWorm *worm)
   }
 }
 
-static void
-gnibbles_worm_handle_bonus (GnibblesWorm *worm)
-{
-  if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
-    (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
-    gnibbles_worm_grok_bonus (worm);
-
-    if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
-	      !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
-      ClutterActor *actor = gnibbles_worm_get_head_actor (worm);
-    clutter_actor_animate (actor, CLUTTER_LINEAR, 300,
-                         "scale-x", 1.3, "scale-y", 1.3,
-                         "fixed::scale-gravity", CLUTTER_GRAVITY_CENTER,
-                         NULL);
-      gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
-      
-      if (boni->numleft != 0)
-	      gnibbles_board_level_add_bonus (board, 1);
-
-    } else
-        gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
-  }
-
-  if (board->walls[worm->xhead][worm->yhead] == WARPLETTER) {
-    gnibbles_warpmanager_worm_change_pos (warpmanager, worm);
-    games_sound_play ("teleport");
-  }
-}
-
 GnibblesWorm*
 gnibbles_worm_new (guint number, guint t_xhead,
 			                    guint t_yhead, gint t_direction)
@@ -644,8 +647,6 @@ gnibbles_worm_move_head (GnibblesWorm *worm)
     worm->keypress = 0;
   
   gnibbles_worm_move_head_pointer (worm);
-  gnibbles_worm_handle_bonus (worm);
-
   worm->length++;
 
   if (key_queue[worm->number] && !g_queue_is_empty (key_queue[worm->number])) {



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