[gnome-games] Small fix to resize worm properly, now reloading pixmaps on resize



commit 2de1ad5de5e52cda8f58dd5563e966eface298f0
Author: Guillaume Beland <guillaume beland gmail com>
Date:   Wed Jun 3 16:29:26 2009 -0400

    Small fix to resize worm properly, now reloading pixmaps on resize

 gnibbles/level.c        |    2 +-
 gnibbles/main.c         |   69 +++++++++++++++++++++++++++++++++++++++++++++++
 gnibbles/main.h         |    2 +-
 gnibbles/worm-clutter.c |    4 ++-
 4 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/gnibbles/level.c b/gnibbles/level.c
index 8b64004..0db6ace 100644
--- a/gnibbles/level.c
+++ b/gnibbles/level.c
@@ -53,7 +53,7 @@ gnibbles_level_new (gint level)
   if ((in = fopen (filename, "r")) == NULL) {
     char *message =
       g_strdup_printf (_
-                       ("Nibbles couldn't load level file:\n%s\n\n"
+                        ("Nibbles couldn't load level file:\n%s\n\n"
                         "Please check your Nibbles installation"), filename);
     //gnibbles_error (window, message);
     g_free (message);
diff --git a/gnibbles/main.c b/gnibbles/main.c
index d08f553..091b441 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -231,6 +231,75 @@ load_pixmap ()
   }
 }
 
+void 
+load_pixmap_with_tilesize (gint tilesize)
+{
+  gchar *bonus_files[] = {
+    "blank.svg",
+    "diamond.svg",
+    "bonus1.svg",
+    "bonus2.svg",
+    "life.svg",
+    "bonus3.svg",
+    "bonus4.svg",
+    "bonus5.svg",
+    "questionmark.svg"
+  };
+
+  gchar *small_files[] = {
+    "wall-straight-up.svg",
+    "wall-straight-side.svg",
+    "wall-corner-bottom-left.svg",
+    "wall-corner-bottom-right.svg",
+    "wall-corner-top-left.svg",
+    "wall-corner-top-right.svg",
+    "wall-tee-up.svg",
+    "wall-tee-right.svg",
+    "wall-tee-left.svg",
+    "wall-tee-down.svg",
+    "wall-cross.svg"
+  };
+  
+  gchar *worm_files[] = {
+    "snake-red.svg",
+    "snake-green.svg",
+    "snake-blue.svg",
+    "snake-yellow.svg",
+    "snake-cyan.svg",
+    "snake-magenta.svg",
+    "snake-grey.svg"
+  };
+
+  int i;
+
+  for (i = 0; i < 9; i++) {
+    if (boni_pixmaps[i])
+      g_object_unref (boni_pixmaps[i]);
+    boni_pixmaps[i] = load_pixmap_file (bonus_files[i],
+ 						  4 * tilesize,
+						  4 * tilesize);
+  }
+
+  for (i = 0; i < 11; i++) {
+    if (wall_pixmaps[i])
+      g_object_unref (wall_pixmaps[i]);
+      
+    wall_pixmaps[i] = load_pixmap_file (small_files[i],
+	 	  		                              2 * tilesize,
+                           						  2 * tilesize);
+  }
+
+  for (i = 0; i < 7; i++) {
+    if (worm_pixmaps[i])
+      g_object_unref (worm_pixmaps[i]);
+
+    worm_pixmaps[i] = load_pixmap_file (worm_files[i],
+                                        tilesize,
+                                        tilesize);
+  }
+}
+
+
 static void
 hide_cursor (void)
 {
diff --git a/gnibbles/main.h b/gnibbles/main.h
index 3dcfc9d..3765553 100644
--- a/gnibbles/main.h
+++ b/gnibbles/main.h
@@ -40,7 +40,7 @@ gint pause_game_cb (GtkAction * action, gpointer data);
 void end_game (gboolean);
 gint new_game (void);
 gint main_loop (gpointer data);
-
+void load_pixmap_with_tilesize (gint tilesize);
 extern GamesScores *highscores;
 extern GtkWidget *notebook;
 extern GtkWidget *window;
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 06e2865..376c904 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -200,6 +200,7 @@ gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
   ClutterActor *tmp;
 
   count = clutter_group_get_n_children (CLUTTER_GROUP (worm->actors));
+  load_pixmap_with_tilesize (newtile);
 
   for (i = 0; i < count; i++) {
     tmp = clutter_group_get_nth_child (CLUTTER_GROUP (worm->actors), i);
@@ -222,8 +223,9 @@ gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
     else
       clutter_actor_set_size (tmp, newtile, newtile * size);
 
+
     //TODO: Resize/Reload pixbuf
-    //gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (tmp), worm_pixmaps[worm->number]);
+    gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (tmp), worm_pixmaps[worm->number]);
   }
 
 }



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