[gnome-games/gnibbles-clutter] Temporary fix to slow down worm's movement ...
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gnibbles-clutter] Temporary fix to slow down worm's movement ...
- Date: Sat, 6 Jun 2009 22:06:33 -0400 (EDT)
commit 402f82e7a9afa4cfdbce522ca91a98eb6538e8df
Author: Guillaume Beland <guillaume beland gmail com>
Date: Sat Jun 6 22:02:19 2009 -0400
Temporary fix to slow down worm's movement ...
... and some general work on worm movement, moved and renamed
gnibbles_cworm_move () from worm-clutter.c to move_worm_cb in main.c as this
callback have nothing to do in worm-clutter.c
---
gnibbles/main.c | 68 ++++++++++++++++++++++++++++++++++++++++++++--
gnibbles/worm-clutter.c | 59 ----------------------------------------
2 files changed, 65 insertions(+), 62 deletions(-)
diff --git a/gnibbles/main.c b/gnibbles/main.c
index 79cbf65..16a67d0 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -1253,6 +1253,67 @@ render_logo (void)
}
+void
+move_worm_cb (ClutterTimeline *timeline, gint msecs, gpointer data)
+{
+ if (msecs % 25 != 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)
{
@@ -1340,13 +1401,14 @@ main (int argc, char **argv)
clutter_actor_raise_top (cworms[i]->actors);
}
- ClutterTimeline *timeline = clutter_timeline_new (2);
+ ClutterTimeline *timeline = clutter_timeline_new (200);
clutter_timeline_set_loop (timeline, TRUE);
cworms[2]->direction = WORMDOWN;
gnibbles_cworm_add_straight_actor (cworms[2]);
+
+ g_signal_connect (timeline, "new-frame", G_CALLBACK (move_worm_cb), NULL);
+ //g_signal_connect (timeline, "new-frame", G_CALLBACK (gnibbles_cworm_move), cworms[3]);
- g_signal_connect (timeline, "new-frame", G_CALLBACK (gnibbles_cworm_move), cworms[2]);
- g_signal_connect (timeline, "new-frame", G_CALLBACK (gnibbles_cworm_move), cworms[3]);
clutter_timeline_start (timeline);
//render_logo_clutter (board);
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 25c79fc..d073e7f 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -219,65 +219,6 @@ gnibbles_cworm_resize (GnibblesCWorm *worm, gint newtile)
gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (tmp), worm_pixmaps[worm->number]);
}
-
-}
-
-void
-gnibbles_cworm_move (ClutterTimeline *timeline, gint msecs, gpointer data)
-{
-
- gfloat w,h;
- gfloat x,y;
- guint size;
- gboolean direction;
- GValue val = {0,};
-
- GnibblesCWorm *worm = (GnibblesCWorm *)data;
-
- ClutterActor *first = g_list_first (worm->list)->data;
- ClutterActor *last = g_list_last (worm->list)->data;
-
- g_value_init (&val, G_TYPE_BOOLEAN);
- 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);
- worm->xhead += properties->tilesize;
- } else {
- clutter_actor_set_size (last, properties->tilesize, properties->tilesize * size);
- clutter_actor_set_position (last, x, y + properties->tilesize);
- worm->yhead += properties->tilesize;
- }
-
- if (size <= 0)
- gnibbles_cworm_remove_actor (worm);
- }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]