[gnome-games/gnibbles-clutter-rebased: 71/129] Factored out code to handle bonus into a new utility function
- From: Jason Clinton <jclinton src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games/gnibbles-clutter-rebased: 71/129] Factored out code to handle bonus into a new utility function
- Date: Mon, 12 Oct 2009 21:32:12 +0000 (UTC)
commit b55e7604c1d75ac2eb6b90a594c21396354589a0
Author: Guillaume Beland <guillaume beland gmail com>
Date: Thu Jul 30 13:50:31 2009 -0400
Factored out code to handle bonus into a new utility function
gnibbles/worm-clutter.c | 78 ++++++++++++++++------------------------------
1 files changed, 27 insertions(+), 51 deletions(-)
---
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index e1c3cce..ac50bd9 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -480,6 +480,26 @@ gnibbles_worm_move_tail_pointer (GnibblesWorm *worm)
}
}
+static void
+gnibbles_worm_handle_bonus (GnibblesWorm *worm)
+{
+ if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
+ (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
+ gnibbles_worm_grok_bonus (worm);
+
+ if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
+ !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
+
+ gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
+
+ if (boni->numleft != 0)
+ gnibbles_board_level_add_bonus (board, 1);
+
+ } else
+ gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
+ }
+}
+
GnibblesWorm*
gnibbles_worm_new (guint number, guint t_xhead,
guint t_yhead, gint t_direction)
@@ -788,25 +808,11 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
break;
}
- gnibbles_worm_move_head_pointer (worm);
gnibbles_worm_move_tail_pointer (worm);
+ gnibbles_worm_move_head_pointer (worm);
- if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
- (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
-
- gnibbles_worm_grok_bonus (worm);
-
- if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
- !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
-
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
-
- if (boni->numleft != 0)
- gnibbles_board_level_add_bonus (board, 1);
+ gnibbles_worm_handle_bonus (worm);
- } else
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
- }
board->walls[worm->xhead][worm->yhead] = WORMCHAR + worm->number;
if (worm->change) {
@@ -830,35 +836,19 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
default:
break;
}
-
- gnibbles_worm_move_head_pointer (worm);
- gnibbles_worm_move_tail_pointer (worm);
-
- if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
- (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
- gnibbles_worm_grok_bonus (worm);
-
- if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
- !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
-
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
+ gnibbles_worm_move_tail_pointer (worm);
+ gnibbles_worm_move_head_pointer (worm);
- if (boni->numleft != 0)
- gnibbles_board_level_add_bonus (board, 1);
-
- } else
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
- }
+ gnibbles_worm_handle_bonus (worm);
board->walls[worm->xhead][worm->yhead] = WORMCHAR + worm->number;
-
board->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
worm->change++;
worm->length--;
}
- board->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
+ board->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
} else {
worm->change--;
worm->length++;
@@ -889,7 +879,6 @@ gnibbles_worm_move_head (GnibblesWorm *worm)
size = w < h ? floorf (h) : floorf (w);
size = floorf (size + properties->tilesize);
- // set the size of the head actor
switch (worm->direction) {
case WORMRIGHT:
clutter_actor_set_width (CLUTTER_ACTOR (head), size);
@@ -913,22 +902,9 @@ gnibbles_worm_move_head (GnibblesWorm *worm)
gnibbles_worm_move_head_pointer (worm);
- if ((board->walls[worm->xhead][worm->yhead] != EMPTYCHAR) &&
- (board->walls[worm->xhead][worm->yhead] != WARPLETTER)) {
-
- gnibbles_worm_grok_bonus (worm);
-
- if ((board->walls[worm->xhead][worm->yhead] == BONUSREGULAR + 'A') &&
- !gnibbles_boni_fake (boni, worm->xhead, worm->yhead)) {
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
- if (boni->numleft != 0)
- gnibbles_board_level_add_bonus (board, 1);
- } else
- gnibbles_boni_remove_bonus_final (boni, worm->xhead, worm->yhead);
- }
+ gnibbles_worm_handle_bonus (worm);
board->walls[worm->xhead][worm->yhead] = WORMCHAR + worm->number;
-
worm->length++;
if (key_queue[worm->number] && !g_queue_is_empty (key_queue[worm->number])) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]