From 072964dc6d54ad2e898e796c0e4245399ee5fd10 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Sat, 31 Oct 2009 15:15:00 +0000 Subject: [PATCH] added a function for changing a piece's shape --- games/tetris/piece.c | 14 ++++++++++++++ games/tetris/piece.h | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/games/tetris/piece.c b/games/tetris/piece.c index 294fc54..ca2c7b6 100644 --- a/games/tetris/piece.c +++ b/games/tetris/piece.c @@ -117,3 +117,17 @@ void tetris_piece_rotate(tetris_piece_t *pPc, } } +/* Function: tetris_piece_change + * Description: changes the shape of a piece + * Argument pPc: piece to change + * Argument shape: the shape of interest + * Return value: void + */ +void tetris_piece_change(tetris_piece_t *pPc, + tetris_piece_shape_t shape) +{ + assert(pPc != NULL); + assert((shape >= 0) && (shape <= TETRIS_PC_Z)); + + pPc->shape = shape; +} diff --git a/games/tetris/piece.h b/games/tetris/piece.h index 0b1e809..ea83b1d 100644 --- a/games/tetris/piece.h +++ b/games/tetris/piece.h @@ -74,7 +74,7 @@ tetris_piece_t *tetris_piece_construct(tetris_piece_shape_t s, ****************************/ /* Function: tetris_piece_getBitmap - * Description: returns bitfield representation of the piece + * Description: returns bitfield representation of the piece * Argument pPc: piece from which the bitfield shuld be retrieved * Return value: bitfield representation of the piece * - nth nibble is nth row of the piece (from upper left) @@ -93,5 +93,14 @@ void tetris_piece_rotate(tetris_piece_t *pPc, tetris_piece_rotation_t r); +/* Function: tetris_piece_change + * Description: changes the shape of a piece + * Argument pPc: piece to change + * Argument shape: the shape of interest + * Return value: void + */ +void tetris_piece_change(tetris_piece_t *pPc, + tetris_piece_shape_t shape); + #endif /*TETRIS_PIECE_H_*/