[gnome-games/gnibbles-clutter] Everything in place to control worm with keyboard, and some more tweak on game
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gnibbles-clutter] Everything in place to control worm with keyboard, and some more tweak on game
- Date: Thu, 2 Jul 2009 18:03:06 +0000 (UTC)
commit 6aa441b73f3938769f41314362ce1d5ba157b034
Author: Guillaume Beland <guillaume beland gmail com>
Date: Thu Jul 2 13:56:07 2009 -0400
Everything in place to control worm with keyboard, and some more tweak on game
logic
It look like I have a clutter and/or hardware problem that I can't seem to
resolve, therefor it's hard to test my progress
gnibbles/main.c | 27 +++++++++++++++++++++++----
gnibbles/worm-clutter.c | 33 +++++++++++++++++++++------------
2 files changed, 44 insertions(+), 16 deletions(-)
---
diff --git a/gnibbles/main.c b/gnibbles/main.c
index fbeeeac..cb17f5c 100644
--- a/gnibbles/main.c
+++ b/gnibbles/main.c
@@ -117,6 +117,7 @@ static gint add_bonus_cb (gpointer data);
static void render_logo (void);
static void render_logo_clutter (void);
static gint end_game_cb (GtkAction * action, gpointer data);
+static void hide_logo (void);
static GtkAction *new_game_action;
static GtkAction *new_network_action;
@@ -129,6 +130,8 @@ static GtkAction *scores_action;
static GtkAction *fullscreen_action;
static GtkAction *leave_fullscreen_action;
+static ClutterActor *landing_page;
+
static void
hide_cursor (void)
{
@@ -591,6 +594,7 @@ new_game_clutter (void)
current_level = rand () % MAXLEVEL + 1;
}
+ hide_logo ();
level = gnibbles_level_new (current_level);
gnibbles_board_load_level (clutter_board, level);
//gnibbles_clutter_add_bonus (1);
@@ -1274,12 +1278,13 @@ render_logo_clutter (void)
ClutterColor actor_color = {0xff,0xff,0xff,0xff};
ClutterActor *stage = gnibbles_board_get_stage (clutter_board);
-
+ landing_page = clutter_group_new ();
clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height);
if (!logo_pixmap)
gnibbles_load_logo ();
+
logo = gtk_clutter_texture_new_from_pixbuf (logo_pixmap);
clutter_actor_set_size (CLUTTER_ACTOR (logo), width, height);
@@ -1294,10 +1299,26 @@ render_logo_clutter (void)
clutter_actor_set_position (CLUTTER_ACTOR (desc), (width / 2) - 170, height - 40);
clutter_actor_show (desc);
- clutter_container_add (CLUTTER_CONTAINER (stage), logo, text, desc, NULL);
+ clutter_container_add (CLUTTER_CONTAINER (stage),
+ CLUTTER_ACTOR (logo),
+ CLUTTER_ACTOR (text),
+ CLUTTER_ACTOR (desc),
+ NULL);
clutter_actor_raise_top (logo);
clutter_actor_raise (text, logo);
clutter_actor_raise (desc, logo);
+
+ clutter_container_add (CLUTTER_CONTAINER (landing_page),
+ CLUTTER_ACTOR (logo),
+ CLUTTER_ACTOR (text),
+ CLUTTER_ACTOR (desc),
+ NULL);
+}
+
+static void
+hide_logo (void)
+{
+ clutter_actor_hide (CLUTTER_ACTOR (landing_page));
}
static void
@@ -1357,8 +1378,6 @@ render_logo (void)
fg_gc[GTK_WIDGET_STATE (drawing_area)], buffer_pixmap,
0, 0, 0, 0, BOARDWIDTH * properties->tilesize,
BOARDHEIGHT * properties->tilesize);
-
-
}
int
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index c8c2baa..d75ca2e 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -268,6 +268,7 @@ gnibbles_cworm_new (guint number, guint t_xhead,
worm->direction_start = t_direction;
gnibbles_cworm_add_actor (worm);
+ gnibbles_worm_queue_empty (worm);
return worm;
}
@@ -472,6 +473,10 @@ gnibbles_cworm_move_straight_worm (GnibblesCWorm *worm)
default:
break;
}
+
+ if (key_queue[worm->number] && !g_queue_is_empty (key_queue[worm->number])) {
+ gnibbles_worm_dequeue_keypress (worm);
+ }
}
void
@@ -528,6 +533,10 @@ gnibbles_cworm_move_head (GnibblesCWorm *worm)
default:
break;
}
+
+ if (key_queue[worm->number] && !g_queue_is_empty (key_queue[worm->number])) {
+ gnibbles_worm_dequeue_keypress (worm);
+ }
}
void
@@ -948,18 +957,18 @@ gnibbles_cworm_ai_wander (gint x, gint y, gint dir, gint ox, gint oy)
dir = 4;
switch (dir) {
- case WORMUP:
- y -= 1;
- break;
- case WORMDOWN:
- y += 1;
- break;
- case WORMLEFT:
- x -= 1;
- break;
- case WORMRIGHT:
- x += 1;
- break;
+ case WORMUP:
+ y -= 1;
+ break;
+ case WORMDOWN:
+ y += 1;
+ break;
+ case WORMLEFT:
+ x -= 1;
+ break;
+ case WORMRIGHT:
+ x += 1;
+ break;
}
if (x >= BOARDWIDTH)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]