[gnome-games/gnibbles-clutter] Solved the collision bug for good, hopefully!
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/gnibbles-clutter] Solved the collision bug for good, hopefully!
- Date: Fri, 7 Aug 2009 15:42:37 +0000 (UTC)
commit 1c3e0ed0c3e968d766af6b96e2992b29669571b7
Author: Guillaume Beland <guillaume beland gmail com>
Date: Fri Aug 7 11:41:40 2009 -0400
Solved the collision bug for good, hopefully!
gnibbles/board.c | 6 +++++-
gnibbles/gnibbles.c | 11 ++++-------
gnibbles/worm-clutter.c | 9 +++++----
gnibbles/worm-clutter.h | 1 -
4 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/gnibbles/board.c b/gnibbles/board.c
index e5b9183..c04e721 100644
--- a/gnibbles/board.c
+++ b/gnibbles/board.c
@@ -325,15 +325,19 @@ gnibbles_board_level_new (GnibblesBoard *board, gint level)
if (worms[i]->direction == WORMRIGHT) {
for (j = 0; j < worms[i]->length; j++)
gnibbles_worm_move_head_pointer (worms[i]);
+ worms[i]->xtail++;
} else if ( worms[i]->direction == WORMLEFT) {
for (j = 0; j < worms[i]->length; j++)
gnibbles_worm_move_head_pointer (worms[i]);
+ worms[i]->xtail--;
} else if (worms[i]->direction == WORMDOWN) {
for (j = 0; j < worms[i]->length; j++)
- gnibbles_worm_move_head_pointer (worms[i]);
+ gnibbles_worm_move_head_pointer (worms[i]);
+ worms[i]->ytail++;
} else if (worms[i]->direction == WORMUP) {
for (j = 0; j < worms[i]->length; j++)
gnibbles_worm_move_head_pointer (worms[i]);
+ worms[i]->ytail--;
}
board->walls[worms[i]->xtail][worms[i]->ytail] = EMPTYCHAR;
}
diff --git a/gnibbles/gnibbles.c b/gnibbles/gnibbles.c
index 865dcb7..c2dafe1 100644
--- a/gnibbles/gnibbles.c
+++ b/gnibbles/gnibbles.c
@@ -270,7 +270,7 @@ gnibbles_move_worms (void)
dead[i] = !gnibbles_worm_test_move_head (worms[i]);
status &= !dead[i];
}
-
+
for (i = 0; i < properties->numworms; i++) {
if (g_list_length (worms[i]->list) > 1 && !dead[i] && worms[i]->lives > 0)
gnibbles_worm_move_tail (worms[i]);
@@ -280,12 +280,9 @@ gnibbles_move_worms (void)
if (g_list_length (worms[i]->list) > 1 && !dead[i] && worms[i]->lives > 0)
gnibbles_worm_move_head (worms[i]);
}
-/*
- for (i = 0; i < properties->numworms; i++) {
- if (g_list_length (worms[i]->list) == 1 && !dead[i] && worms[i]->lives > 0)
- gnibbles_worm_move_straight_worm (worms[i]);
- }
-*/
+
+ //printf ("XHEAD: %d, YHEAD %d \n", worms[0]->xhead, worms[0]->yhead);
+ //printf ("XTAIL: %d, YTAIL %d \n", worms[0]->xtail, worms[0]->ytail);
for (i = 0; i < properties->numworms; i++) {
if (worms[i]->xhead >= BOARDWIDTH) {
worms[i]->xhead = 0;
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index c33ca8f..9b9d328 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -343,7 +343,7 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
}
board->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
}
- /* DEBUG */
+ /* DEBUG *//*
gint i;
FILE *fo;
fo = fopen ("output.txt", "w" );
@@ -357,6 +357,7 @@ gnibbles_worm_reset (ClutterAnimation *animation, gpointer data)
fprintf (fo, "\n");
}
fclose (fo);
+ */
}
static void *
@@ -415,6 +416,7 @@ gnibbles_worm_move_tail_pointer (GnibblesWorm *worm)
gint tail_dir = gnibbles_worm_get_tail_direction (worm);
gnibbles_worm_remove_actor (worm);
+
switch (tail_dir) {
case WORMRIGHT:
worm->xtail++;
@@ -477,12 +479,10 @@ gnibbles_worm_new (guint number, guint t_xhead,
worm->xtail = t_xhead;
worm->ytail = t_yhead;
- worm->start = 0;
- worm->stop = 0;
worm->direction = t_direction;
worm->direction_start = t_direction;
worm->length = SLENGTH;
- worm->change = 0;
+ worm->change = 0;
gnibbles_worm_queue_empty (worm);
@@ -1005,6 +1005,7 @@ gnibbles_worm_ai_move (GnibblesWorm * worm)
if (dir < 1)
dir = 4;
worm->direction = dir;
+
}
}
}
diff --git a/gnibbles/worm-clutter.h b/gnibbles/worm-clutter.h
index d9bc7b6..9ede1f5 100644
--- a/gnibbles/worm-clutter.h
+++ b/gnibbles/worm-clutter.h
@@ -49,7 +49,6 @@ typedef struct {
gint lives;
guint score;
guint number;
- gint start, stop;
gint change;
gint keypress;
gboolean human;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]