[gnome-games/gnibbles-clutter] Fixed keyboard control
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gnibbles-clutter] Fixed keyboard control
- Date: Fri, 17 Jul 2009 22:54:38 +0000 (UTC)
commit ddc41ef54fa21799801145f963d015e2a4b5e2be
Author: Guillaume Beland <guillaume beland gmail com>
Date: Fri Jul 17 18:53:19 2009 -0400
Fixed keyboard control
gnibbles/gnibbles.c | 10 +++++++---
gnibbles/worm-clutter.c | 22 ++++++++++------------
gnibbles/worm-clutter.h | 1 +
3 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/gnibbles/gnibbles.c b/gnibbles/gnibbles.c
index 509ba28..2d5a330 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -210,6 +210,9 @@ gnibbles_init ()
}
}
+ for (i = 0; i < properties->human; i++)
+ worms[i]->human = TRUE;
+
gnibbles_scoreboard_update (scoreboard);
}
@@ -462,9 +465,10 @@ gnibbles_keypress_worms (guint keyval)
gint numworms = ggz_network_mode ? 1 : properties->numworms;
for (i = 0; i < numworms; i++) {
- if (gnibbles_worm_handle_keypress (worms[i], keyval)) {
- return TRUE;
- }
+ if (worms[i]->human)
+ if (gnibbles_worm_handle_keypress (worms[i], keyval)) {
+ return TRUE;
+ }
}
return FALSE;
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 5ca29d8..16370bc 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -79,7 +79,7 @@ gnibbles_worm_queue_keypress (GnibblesWorm * worm, guint dir)
(dir == ((key_queue_entry *) g_queue_peek_tail (key_queue[n]))->dir))
return;
- entry = g_malloc (sizeof (key_queue_entry));
+ entry = g_new (key_queue_entry, 1);
entry->worm = worm;
entry->dir = dir;
g_queue_push_tail (key_queue[n], (gpointer) entry);
@@ -88,10 +88,8 @@ gnibbles_worm_queue_keypress (GnibblesWorm * worm, guint dir)
void
worm_set_direction (int worm, int dir)
{
-
- if (worm >= properties->human) {
+ if (!worms[worm]->human)
return;
- }
if (worms[worm]) {
@@ -171,10 +169,6 @@ gnibbles_worm_handle_keypress (GnibblesWorm * worm, guint keyval)
{
GnibblesWormProps *props;
guint propsUp, propsLeft, propsDown, propsRight, keyvalUpper;
-/* if (worm->keypress) {
- gnibbles_worm_queue_keypress (worm, keyval);
- return FALSE;
- } */
props = properties->wormprops[ggz_network_mode ? 0 : worm->number];
propsUp = toupper(props->up);
@@ -196,22 +190,26 @@ gnibbles_worm_handle_keypress (GnibblesWorm * worm, guint keyval)
return TRUE;
} else {
if ((keyvalUpper == propsUp) && (worm->direction != WORMDOWN)) {
- worm_handle_direction (worm->number, WORMUP);
+ //worm_handle_direction (worm->number, WORMUP);
+ worm->direction = WORMUP;
gnibbles_worm_add_actor (worm);
return TRUE;
}
if ((keyvalUpper == propsRight) && (worm->direction != WORMLEFT)) {
- worm_handle_direction (worm->number, WORMRIGHT);
+ //worm_handle_direction (worm->number, WORMRIGHT);
+ worm->direction = WORMRIGHT;
gnibbles_worm_add_actor (worm);
return TRUE;
}
if ((keyvalUpper == propsDown) && (worm->direction != WORMUP)) {
- worm_handle_direction (worm->number, WORMDOWN);
+ //worm_handle_direction (worm->number, WORMDOWN);
+ worm->direction = WORMDOWN;
gnibbles_worm_add_actor (worm);
return TRUE;
}
if ((keyvalUpper == propsLeft) && (worm->direction != WORMRIGHT)) {
- worm_handle_direction (worm->number, WORMLEFT);
+ //worm_handle_direction (worm->number, WORMLEFT);
+ worm->direction = WORMLEFT;
gnibbles_worm_add_actor (worm);
return TRUE;
}
diff --git a/gnibbles/worm-clutter.h b/gnibbles/worm-clutter.h
index 5269694..fba2498 100644
--- a/gnibbles/worm-clutter.h
+++ b/gnibbles/worm-clutter.h
@@ -54,6 +54,7 @@ typedef struct {
gint stop;
gint change;
gint keypress;
+ gboolean human;
} GnibblesWorm;
void worm_set_direction (int worm, int dir);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]