[gnome-games/gnibbles-clutter] More trivial code refactoring
- From: Guillaume Béland <guillaubel src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/gnibbles-clutter] More trivial code refactoring
- Date: Mon, 27 Jul 2009 15:34:57 +0000 (UTC)
commit 478001df436f7177f3507a050fb2c93cf13bda27
Author: Guillaume Beland <guillaume beland gmail com>
Date: Fri Jul 24 20:04:10 2009 -0400
More trivial code refactoring
replaced set_position to set_x set_y when only one parameters need to be
changed, did the same thing for set_size with set_width and set_height
gnibbles/worm-clutter.c | 82 ++++++++++++++++++-----------------------------
1 files changed, 31 insertions(+), 51 deletions(-)
---
diff --git a/gnibbles/worm-clutter.c b/gnibbles/worm-clutter.c
index 13b2698..8916323 100644
--- a/gnibbles/worm-clutter.c
+++ b/gnibbles/worm-clutter.c
@@ -661,8 +661,8 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
switch (worm->direction) {
case WORMRIGHT:
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x + properties->tilesize, y);
+ clutter_actor_set_x (CLUTTER_ACTOR (head),
+ x + properties->tilesize);
level->walls[++worm->xhead][worm->yhead] = WORMCHAR;
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->xtail == BOARDWIDTH)
@@ -671,8 +671,8 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
worm->xtail++;
break;
case WORMDOWN:
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x, y + properties->tilesize);
+ clutter_actor_set_y (CLUTTER_ACTOR (head),
+ y + properties->tilesize);
level->walls[worm->xhead][++worm->yhead] = WORMCHAR;
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->ytail == BOARDHEIGHT)
@@ -681,8 +681,8 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
worm->ytail++;
break;
case WORMLEFT:
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x - properties->tilesize, y);
+ clutter_actor_set_x (CLUTTER_ACTOR (head),
+ x - properties->tilesize);
level->walls[--worm->xhead][worm->yhead] = WORMCHAR;
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->xtail == 0)
@@ -691,8 +691,8 @@ gnibbles_worm_move_straight_worm (GnibblesWorm *worm)
worm->xtail--;
break;
case WORMUP:
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x, y - properties->tilesize);
+ clutter_actor_set_y (CLUTTER_ACTOR (head),
+ y - properties->tilesize);
level->walls[worm->xhead][--worm->yhead] = WORMCHAR;
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->ytail == 0)
@@ -746,31 +746,23 @@ gnibbles_worm_move_head (GnibblesWorm *worm)
// set the size of the head actor
switch (worm->direction) {
case WORMRIGHT:
- clutter_actor_set_size (CLUTTER_ACTOR (head),
- size,
- properties->tilesize);
+ clutter_actor_set_width (CLUTTER_ACTOR (head), size);
level->walls[++worm->xhead][worm->yhead] = WORMCHAR;
break;
case WORMDOWN:
- clutter_actor_set_size (CLUTTER_ACTOR (head),
- properties->tilesize,
- size);
+ clutter_actor_set_height (CLUTTER_ACTOR (head), size);
level->walls[worm->xhead][++worm->yhead] = WORMCHAR;
break;
case WORMLEFT:
- clutter_actor_set_size (CLUTTER_ACTOR (head),
- size,
- properties->tilesize);
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x - properties->tilesize, y);
+ clutter_actor_set_width (CLUTTER_ACTOR (head), size);
+ clutter_actor_set_x (CLUTTER_ACTOR (head),
+ x - properties->tilesize);
level->walls[--worm->xhead][worm->yhead] = WORMCHAR;
break;
case WORMUP:
- clutter_actor_set_size (CLUTTER_ACTOR (head),
- properties->tilesize,
- size);
- clutter_actor_set_position (CLUTTER_ACTOR (head),
- x, y - properties->tilesize);
+ clutter_actor_set_height (CLUTTER_ACTOR (head), size);
+ clutter_actor_set_y (CLUTTER_ACTOR (head),
+ y - properties->tilesize);
level->walls[worm->xhead][--worm->yhead] = WORMCHAR;
break;
default:
@@ -807,11 +799,9 @@ gnibbles_worm_move_tail (GnibblesWorm *worm)
tail_dir = gnibbles_worm_get_tail_direction (worm);
switch (tail_dir) {
case WORMRIGHT:
- clutter_actor_set_size (CLUTTER_ACTOR (tail),
- size,
- properties->tilesize);
- clutter_actor_set_position (CLUTTER_ACTOR (tail),
- x + properties->tilesize, y);
+ clutter_actor_set_width (CLUTTER_ACTOR (tail), size);
+ clutter_actor_set_x (CLUTTER_ACTOR (tail),
+ x + properties->tilesize);
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->xtail == BOARDWIDTH)
@@ -820,11 +810,9 @@ gnibbles_worm_move_tail (GnibblesWorm *worm)
worm->xtail++;
break;
case WORMDOWN:
- clutter_actor_set_size (CLUTTER_ACTOR (tail),
- properties->tilesize,
- size);
- clutter_actor_set_position (CLUTTER_ACTOR (tail),
- x, y + properties->tilesize);
+ clutter_actor_set_height (CLUTTER_ACTOR (tail), size);
+ clutter_actor_set_y (CLUTTER_ACTOR (tail),
+ y + properties->tilesize);
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->ytail == BOARDHEIGHT)
worm->ytail = 0;
@@ -832,9 +820,7 @@ gnibbles_worm_move_tail (GnibblesWorm *worm)
worm->ytail++;
break;
case WORMLEFT:
- clutter_actor_set_size (CLUTTER_ACTOR (tail),
- size,
- properties->tilesize);
+ clutter_actor_set_width (CLUTTER_ACTOR (tail), size);
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->xtail == 0)
worm->xtail = BOARDWIDTH - 1;
@@ -842,9 +828,7 @@ gnibbles_worm_move_tail (GnibblesWorm *worm)
worm->xtail--;
break;
case WORMUP:
- clutter_actor_set_size (CLUTTER_ACTOR (tail),
- properties->tilesize,
- size);
+ clutter_actor_set_height (CLUTTER_ACTOR (tail), size);
level->walls[worm->xtail][worm->ytail] = EMPTYCHAR;
if (worm->ytail == 0)
worm->ytail = BOARDHEIGHT - 1;
@@ -885,30 +869,26 @@ gnibbles_worm_shrink (GnibblesWorm *worm, gint shrinksize)
clutter_actor_set_position (CLUTTER_ACTOR (tmp),
worm->xtail * properties->tilesize,
worm->ytail * properties->tilesize);
- clutter_actor_set_size (CLUTTER_ACTOR (tmp),
- properties->tilesize,
+ clutter_actor_set_height (CLUTTER_ACTOR (tmp),
(actor_size - shrinksize) * properties->tilesize);
break;
case WORMUP:
worm->ytail -= shrinksize;
- clutter_actor_set_size (CLUTTER_ACTOR (tmp),
- (actor_size - shrinksize) * properties->tilesize,
- properties->tilesize);
+ clutter_actor_set_height (CLUTTER_ACTOR (tmp),
+ (actor_size - shrinksize) * properties->tilesize);
break;
case WORMRIGHT:
worm->xtail += shrinksize;
clutter_actor_set_position (CLUTTER_ACTOR (tmp),
worm->xtail * properties->tilesize,
worm->ytail * properties->tilesize);
- clutter_actor_set_size (CLUTTER_ACTOR (tmp),
- (actor_size - shrinksize) * properties->tilesize,
- properties->tilesize);
+ clutter_actor_set_width (CLUTTER_ACTOR (tmp),
+ (actor_size - shrinksize) * properties->tilesize);
break;
case WORMLEFT:
worm->xtail -= shrinksize;
- clutter_actor_set_size (CLUTTER_ACTOR (tmp),
- (actor_size - shrinksize) * properties->tilesize,
- properties->tilesize);
+ clutter_actor_set_width (CLUTTER_ACTOR (tmp),
+ (actor_size - shrinksize) * properties->tilesize);
break;
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]