[gnome-games] Properly reseting worm's live and score on new game



commit ca04d76a099d4cfe227c0a9cc0967537026e11f7
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Sat Aug 22 13:14:51 2009 -0400

    Properly reseting worm's live and score on new game

 gnibbles/board.c    |    4 ----
 gnibbles/gnibbles.c |   16 ++++++----------
 gnibbles/main.c     |   13 ++++++++++---
 3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/gnibbles/board.c b/gnibbles/board.c
index 5402e06..22fe8d5 100644
--- a/gnibbles/board.c
+++ b/gnibbles/board.c
@@ -247,10 +247,6 @@ gnibbles_board_level_new (GnibblesBoard *board, gint level)
 
   boni = gnibbles_boni_new ();
 
-  for (i = 0; i < properties->numworms; i++)
-    if (!worms[i])
-      worms[i] = gnibbles_worm_new (i);
-
   for (i = 0; i < BOARDHEIGHT; i++) {
     if (!fgets (tmpboard, sizeof (tmpboard), in)) {
       char *message =
diff --git a/gnibbles/gnibbles.c b/gnibbles/gnibbles.c
index 8d629be..81c6267 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -201,23 +201,19 @@ gnibbles_init ()
 
   gint i;
 
+  for (i = 0; i < properties->numworms; i++) {
+    if (worms[i])
+      gnibbles_worm_destroy (worms[i]);
+  }
+
   gnibbles_scoreboard_clear (scoreboard);
 
   for (i = 0; i < properties->numworms; i++) {
+    worms[i] = gnibbles_worm_new (i);
     gnibbles_scoreboard_register (scoreboard, worms[i], 
                    colorval_name (properties->wormprops[i]->color));
   }
 
-  for (i = 0; i < properties->numworms; i++) {
-    if (worms[i]) {
-      if (!clutter_actor_get_stage (worms[i]->actors)) {
-        clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors);
-        clutter_actor_raise_top (worms[i]->actors);
-      }
-      gnibbles_worm_show (worms[i]);
-    }
-  }
-
   for (i = 0; i < properties->human; i++)
     worms[i]->human = TRUE;
 
diff --git a/gnibbles/main.c b/gnibbles/main.c
index b4dd73b..30697b4 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -359,6 +359,8 @@ new_game_2_cb (GtkWidget * widget, gpointer data)
 gboolean
 new_game (void)
 {
+  int i;
+
   gtk_action_set_sensitive (new_network_action, FALSE);
 
   if (ggz_network_mode) {
@@ -374,7 +376,6 @@ new_game (void)
     main_id = 0;
   }
 
-
   if (ggz_network_mode || !properties->random) {
     current_level = properties->startlevel;
   } else {
@@ -382,10 +383,16 @@ new_game (void)
   }
 
   hide_logo ();
+  gnibbles_init ();
   gnibbles_board_level_new (board, current_level);
   gnibbles_board_level_add_bonus (board, 1);
-  gnibbles_init ();
 
+  for (i = 0; i < properties->numworms; i++) {
+    if (!clutter_actor_get_stage (worms[i]->actors))
+      clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors);
+    gnibbles_worm_show (worms[i]);
+  }
+  
   paused = 0;
   gtk_action_set_visible (pause_action, !paused);
   gtk_action_set_visible (resume_action, paused);
@@ -526,7 +533,7 @@ restart_game (gpointer data)
 
   gnibbles_board_level_new (board, current_level);
   gnibbles_board_level_add_bonus (board, 1);
-  
+ 
   for (i = 0; i < properties->numworms; i++) {
     if (!clutter_actor_get_stage (worms[i]->actors))
       clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors);



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