[gnome-games/gnibbles-clutter-rebased: 16/129] minor fixes
- From: Jason Clinton <jclinton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/gnibbles-clutter-rebased: 16/129] minor fixes
- Date: Mon, 12 Oct 2009 21:27:34 +0000 (UTC)
commit 1613733cbc338edabba5d06d39c7593a2a3618a5
Author: Guillaume Beland <guillaume beland gmail com>
Date: Mon Jun 15 16:33:50 2009 -0400
minor fixes
gnibbles/main.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++-
gnibbles/worm-clutter.c | 1 -
2 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 85858bd..28f5774 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -1260,6 +1260,67 @@ render_logo (void)
}
+static void
+move_worm_cb (ClutterTimeline *timeline, gint msecs, gpointer data)
+{
+ if (msecs % 19 != 0)
+ return;
+
+ gfloat w,h;
+ gfloat x,y;
+ guint size;
+ gboolean direction;
+ GValue val = {0,};
+ gint i;
+ g_value_init (&val, G_TYPE_BOOLEAN);
+
+ for (i = 0; i < 4 /*numworms*/; i++) {
+ ClutterActor *first = g_list_first (cworms[i]->list)->data;
+ ClutterActor *last = g_list_last (cworms[i]->list)->data;
+
+ g_object_get_property (G_OBJECT (first), "repeat-x", &val);
+ direction = g_value_get_boolean (&val);
+
+ if (first == last) {
+ clutter_actor_get_position (CLUTTER_ACTOR (first), &x, &y);
+ if (direction)
+ clutter_actor_set_position (CLUTTER_ACTOR (first), x + properties->tilesize, y);
+ else
+ clutter_actor_set_position (CLUTTER_ACTOR (first), x, y + properties->tilesize);
+ } else {
+
+ clutter_actor_get_size (CLUTTER_ACTOR (first), &w, &h);
+ size = w < h ? h : w;
+
+ if (direction)
+ clutter_actor_set_size (first, properties->tilesize + size, properties->tilesize);
+ else
+ clutter_actor_set_size (first, properties->tilesize, properties->tilesize + size);
+
+ g_object_get_property (G_OBJECT (last), "repeat-x", &val);
+ direction = g_value_get_boolean (&val);
+ clutter_actor_get_size (CLUTTER_ACTOR (last), &w, &h);
+ clutter_actor_get_position (CLUTTER_ACTOR (last), &x, &y);
+ size = w < h ? h : w;
+ size = size / (properties->tilesize + 1);
+
+ //TODO: Set move UP/DOWn RIGHT/LEFT
+ if (direction) {
+ clutter_actor_set_size (last, properties->tilesize * size, properties->tilesize);
+ clutter_actor_set_position (last, x + properties->tilesize, y);
+ cworms[i]->xhead += properties->tilesize;
+ } else {
+ clutter_actor_set_size (last, properties->tilesize, properties->tilesize * size);
+ clutter_actor_set_position (last, x, y + properties->tilesize);
+ cworms[i]->yhead += properties->tilesize;
+ }
+
+ if (size <= 0)
+ gnibbles_cworm_remove_actor (cworms[i]);
+ }
+ }
+}
+
int
main (int argc, char **argv)
{
@@ -1349,7 +1410,7 @@ main (int argc, char **argv)
clutter_actor_raise_top (cworms[i]->actors);
}
- ClutterTimeline *timeline = clutter_timeline_new (10, 6);
+ ClutterTimeline *timeline = clutter_timeline_new (20);
clutter_timeline_set_loop (timeline, TRUE);
cworms[2]->direction = WORMDOWN;
gnibbles_cworm_add_straight_actor (cworms[2]);
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index f3aa30d..d6794dc 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -134,7 +134,6 @@ gnibbles_cworm_add_straight_actor (GnibblesCWorm *worm)
worm->list = g_list_prepend (worm->list, actor);
- //TODO: connect/timeline: start increasing the size of the actor
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]