[gnome-games/gnibbles-clutter] Fixed worm resizing for good
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gnibbles-clutter] Fixed worm resizing for good
- Date: Wed, 3 Jun 2009 17:34:07 -0400 (EDT)
commit 48b7aa96092cbea72a2a4b9e5b87e086157195e0
Author: Guillaume Beland <guillaume beland gmail com>
Date: Wed Jun 3 17:18:55 2009 -0400
Fixed worm resizing for good
---
gnibbles/main.c | 84 ++++-------------------------------------------
gnibbles/main.h | 3 +-
gnibbles/worm-clutter.c | 10 +++---
3 files changed, 14 insertions(+), 83 deletions(-)
diff --git a/gnibbles/main.c b/gnibbles/main.c
index b13263d..be9fc12 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -163,76 +163,8 @@ load_pixmap_file (const gchar * pixmap, gint xsize, gint ysize)
return image;
}
-static void
-load_pixmap ()
-{
- 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 * properties->tilesize,
- 4 * properties->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 * properties->tilesize,
- 2 * properties->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],
- properties->tilesize,
- properties->tilesize);
- }
-}
-
void
-load_pixmap_with_tilesize (gint tilesize)
+load_pixmap (gint tilesize)
{
gchar *bonus_files[] = {
"blank.svg",
@@ -275,9 +207,10 @@ load_pixmap_with_tilesize (gint tilesize)
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);
+ 4 * tilesize,
+ 4 * tilesize);
}
for (i = 0; i < 11; i++) {
@@ -285,7 +218,7 @@ load_pixmap_with_tilesize (gint tilesize)
g_object_unref (wall_pixmaps[i]);
wall_pixmaps[i] = load_pixmap_file (small_files[i],
- 2 * tilesize,
+ 2 * tilesize,
2 * tilesize);
}
@@ -293,13 +226,10 @@ load_pixmap_with_tilesize (gint tilesize)
if (worm_pixmaps[i])
g_object_unref (worm_pixmaps[i]);
- worm_pixmaps[i] = load_pixmap_file (worm_files[i],
- tilesize,
- tilesize);
+ worm_pixmaps[i] = load_pixmap_file (worm_files[i], tilesize,tilesize);
}
}
-
static void
hide_cursor (void)
{
@@ -1391,7 +1321,7 @@ main (int argc, char **argv)
// clutter fun
gtk_clutter_init (&argc, &argv);
- load_pixmap ();
+ load_pixmap (properties->tilesize);
GnibblesBoard *board = gnibbles_board_new (BOARDWIDTH, BOARDHEIGHT);
setup_window_clutter (board);
diff --git a/gnibbles/main.h b/gnibbles/main.h
index 3765553..76870ce 100644
--- a/gnibbles/main.h
+++ b/gnibbles/main.h
@@ -40,7 +40,8 @@ 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);
+void load_pixmap (gint tilesize);
+
extern GamesScores *highscores;
extern GtkWidget *notebook;
extern GtkWidget *window;
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 376c904..4614793 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -181,6 +181,7 @@ gnibbles_cworm_lose_life (GnibblesCWorm * worm)
return 0;
}
+
void
gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
{
@@ -200,7 +201,9 @@ gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
ClutterActor *tmp;
count = clutter_group_get_n_children (CLUTTER_GROUP (worm->actors));
- load_pixmap_with_tilesize (newtile);
+ load_pixmap (newtile);
+
+ g_value_init (&val, G_TYPE_BOOLEAN);
for (i = 0; i < count; i++) {
tmp = clutter_group_get_nth_child (CLUTTER_GROUP (worm->actors), i);
@@ -210,21 +213,18 @@ gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
(x_pos / properties->tilesize) * newtile,
(y_pos / properties->tilesize) * newtile);
- g_value_init (&val, G_TYPE_BOOLEAN);
g_object_get_property (G_OBJECT (tmp), "repeat-x", &val);
direction = g_value_get_boolean (&val);
clutter_actor_get_size (CLUTTER_ACTOR (tmp), &w, &h);
size = w < h ? h : w;
- size = size / newtile;
+ size = size / properties->tilesize;
if (direction)
clutter_actor_set_size (tmp, newtile * size, 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]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]