[gnome-games/gnibbles-clutter-rebased: 76/129] Re-integrated proper warp management



commit b2572dd8303dd5c4771e37e2b9dc3fd4f23f8a23
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Tue Aug 4 14:31:48 2009 -0400

    Re-integrated proper warp management

 gnibbles/bonus.c        |   30 +++++++++++++++---------------
 gnibbles/warp.c         |    1 +
 gnibbles/warpmanager.c  |   17 +++--------------
 gnibbles/warpmanager.h  |    8 ++++----
 gnibbles/worm-clutter.c |    6 ++++++
 5 files changed, 29 insertions(+), 33 deletions(-)
---
diff --git a/gnibbles/bonus.c b/gnibbles/bonus.c
index 482ffb2..9c079f1 100644
--- a/gnibbles/bonus.c
+++ b/gnibbles/bonus.c
@@ -38,6 +38,21 @@ extern GnibblesProperties *properties;
 extern GnibblesBoard *board;
 extern ClutterActor *stage;
 
+static void
+animate_bonus (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);
+  clutter_animation_set_loop (anim, TRUE);
+  
+}
+
 GnibblesBonus *
 gnibbles_bonus_new (gint t_x, gint t_y, gint t_type,
 		    gint t_fake, gint t_countdown)
@@ -55,21 +70,6 @@ gnibbles_bonus_new (gint t_x, gint t_y, gint t_type,
   return (tmp);
 }
 
-static void
-animate_bonus (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);
-  clutter_animation_set_loop (anim, TRUE);
-  
-}
-
 void
 gnibbles_bonus_draw (GnibblesBonus *bonus)
 {
diff --git a/gnibbles/warp.c b/gnibbles/warp.c
index ae67db5..e366c5a 100644
--- a/gnibbles/warp.c
+++ b/gnibbles/warp.c
@@ -33,6 +33,7 @@ extern GnibblesProperties *properties;
 extern GdkPixbuf *boni_pixmaps[];
 extern GnibblesBoard *board;
 extern ClutterActor *stage;
+
 GnibblesWarp *
 gnibbles_warp_new (gint t_x, gint t_y, gint t_wx, gint t_wy)
 {
diff --git a/gnibbles/warpmanager.c b/gnibbles/warpmanager.c
index 902311a..f5afab3 100644
--- a/gnibbles/warpmanager.c
+++ b/gnibbles/warpmanager.c
@@ -105,8 +105,7 @@ gnibbles_warpmanager_add_warp (GnibblesWarpManager * warpmanager, gint t_x,
     gnibbles_warp_draw (warpmanager->warps[draw]);
   }
 }
-// useless ?
-/*
+
 void
 gnibbles_warpmanager_worm_change_pos (GnibblesWarpManager * warpmanager,
 				                              GnibblesWorm * worm)
@@ -134,28 +133,18 @@ gnibbles_warpmanager_worm_change_pos (GnibblesWarpManager * warpmanager,
 	          x = rand () % BOARDWIDTH;
 	          y = rand () % BOARDHEIGHT;
 	        }
-	        if (board[x][y] == EMPTYCHAR)
-	          good = 1;
-          //gnibbles-clutter-level
-	        if (level->walls[x][y] == EMPTYCHAR)
+	        if (board->walls[x][y] == EMPTYCHAR)
 	          good = 1;
 	      }
       } else {
 	      x = warpmanager->warps[i]->wx;
 	      y = warpmanager->warps[i]->wy;
-	      if (board[x][y] != EMPTYCHAR)
-	        gnibbles_boni_remove_bonus (boni, x, y);
-        //gnibbles->clutter-level
-	      if (level->walls[x][y] != EMPTYCHAR)
+	      if (board->walls[x][y] != EMPTYCHAR)
 	        gnibbles_boni_remove_bonus (boni, x, y);
       }
-      //TODO: handle worm in wrap
-      worm->xoff[worm->start] += worm->xhead - x;
-      worm->yoff[worm->start] += worm->yhead - y;
 
       worm->xhead = x;
       worm->yhead = y;
     }
   }
 }
-*/
diff --git a/gnibbles/warpmanager.h b/gnibbles/warpmanager.h
index 6e0b421..88544a8 100644
--- a/gnibbles/warpmanager.h
+++ b/gnibbles/warpmanager.h
@@ -25,7 +25,7 @@
 #include <gtk/gtk.h>
 
 #include "warp.h"
-//#include "worm.h"
+#include "worm-clutter.h"
 
 #define MAXWARPS 200
 #define WARPLETTER 'W'
@@ -40,9 +40,9 @@ GnibblesWarpManager *gnibbles_warpmanager_new (void);
 void gnibbles_warpmanager_destroy (GnibblesWarpManager * warpmanager);
 
 void gnibbles_warpmanager_add_warp (GnibblesWarpManager * warpmanager,
-				    gint t_x, gint t_y, gint t_wx, gint t_wy);
+				                            gint t_x, gint t_y, gint t_wx, gint t_wy);
 
-//void gnibbles_warpmanager_worm_change_pos (GnibblesWarpManager * warpmanager,
-//					   GnibblesWorm * worm);
+void gnibbles_warpmanager_worm_change_pos (GnibblesWarpManager * warpmanager,
+					                                 GnibblesWorm * worm);
 
 #endif
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 0e4e338..705a983 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -455,6 +455,7 @@ gnibbles_worm_move_head_pointer (GnibblesWorm *worm)
     worm->yhead = 0;
   if (worm->yhead < 0) 
     worm->yhead = BOARDHEIGHT - 1;
+
 }
 
 static void
@@ -498,6 +499,11 @@ gnibbles_worm_handle_bonus (GnibblesWorm *worm)
     } 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*



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