[gnome-games] Fixed keyboard control
- From: Jason Clinton <jclinton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] Fixed keyboard control
- Date: Wed, 14 Oct 2009 02:50:44 +0000 (UTC)
commit 8b5d5258b2239c5edad377fcffd3822cc962af80
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 cf57c13..719c1a5 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -211,6 +211,9 @@ gnibbles_init ()
}
}
+ for (i = 0; i < properties->human; i++)
+ worms[i]->human = TRUE;
+
gnibbles_scoreboard_update (scoreboard);
}
@@ -463,9 +466,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 0d16051..7d1aeeb 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]