[gnome-games/gnibbles-clutter] Resizing bonus on configure event
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/gnibbles-clutter] Resizing bonus on configure event
- Date: Tue, 11 Aug 2009 17:42:08 +0000 (UTC)
commit eddab793b67e87387d8cac7aa7c88ae4f3b977fb
Author: Guillaume Beland <guillaume beland gmail com>
Date: Tue Aug 11 13:14:37 2009 -0400
Resizing bonus on configure event
gnibbles/boni.c | 26 ++++++++++++++++++++++++++
gnibbles/boni.h | 7 ++++---
gnibbles/main.c | 1 +
3 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/gnibbles/boni.c b/gnibbles/boni.c
index d396195..4d362f3 100644
--- a/gnibbles/boni.c
+++ b/gnibbles/boni.c
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <libgames-support/games-sound.h>
+#include <clutter-gtk/clutter-gtk.h>
#include "gnibbles.h"
#include "main.h"
@@ -32,8 +33,11 @@
#include "boni.h"
#include "ggz-network.h"
#include "board.h"
+#include "properties.h"
extern GnibblesBoard *board;
+extern GnibblesProperties *properties;
+extern GdkPixbuf *boni_pixmaps[];
GnibblesBoni *
gnibbles_boni_new (void)
@@ -184,3 +188,25 @@ gnibbles_boni_remove_bonus_final (GnibblesBoni * boni, gint x, gint y)
}
}
}
+
+void
+gnibbles_boni_resize (GnibblesBoni *boni, gint newtile)
+{
+ int i;
+ gfloat x_pos, y_pos;
+ GError *err = NULL;
+
+ for (i = 0; i < boni->numbonuses; i++) {
+ clutter_actor_get_position (boni->bonuses[i]->actor, &x_pos, &y_pos);
+
+ clutter_actor_set_position (boni->bonuses[i]->actor,
+ (x_pos / properties->tilesize) * newtile,
+ (y_pos / properties->tilesize) * newtile);
+
+ gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE(boni->bonuses[i]->actor),
+ boni_pixmaps[boni->bonuses[i]->type],
+ &err);
+ if (err)
+ gnibbles_error (err->message);
+ }
+}
diff --git a/gnibbles/boni.h b/gnibbles/boni.h
index f75e872..0502c4a 100644
--- a/gnibbles/boni.h
+++ b/gnibbles/boni.h
@@ -43,13 +43,14 @@ GnibblesBoni *gnibbles_boni_new (void);
void gnibbles_boni_destroy (GnibblesBoni * boni);
void gnibbles_boni_add_bonus (GnibblesBoni * boni, gint t_x, gint t_y,
- gint t_type, gint t_fake, gint t_countdown);
+ gint t_type, gint t_fake, gint t_countdown);
void gnibbles_boni_remove_bonus (GnibblesBoni * boni, gint x, gint y);
void gnibbles_boni_add_bonus_final (GnibblesBoni * boni, gint t_x, gint t_y,
- gint t_type, gint t_fake,
- gint t_countdown);
+ gint t_type, gint t_fake, gint t_countdown);
void gnibbles_boni_remove_bonus_final (GnibblesBoni * boni, gint x, gint y);
int gnibbles_boni_fake (GnibblesBoni * boni, gint x, gint y);
+void gnibbles_boni_resize (GnibblesBoni *boni, gint newtile);
+
#endif
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 86a09a3..f406f9f 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -286,6 +286,7 @@ configure_event_cb (GtkWidget * widget, GdkEventConfigure * event, gpointer data
if (game_running ()) {
if (board) {
gnibbles_board_resize (board, tilesize);
+ gnibbles_boni_resize (boni, tilesize);
for (i=0; i<properties->numworms; i++)
gnibbles_worm_resize (worms[i], tilesize);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]