added functions to change pieces and determine their number of different angles
This commit is contained in:
parent
6aaf4b0c2e
commit
42bebccfba
|
@ -117,13 +117,13 @@ void tetris_piece_rotate(tetris_piece_t *pPc,
|
|||
}
|
||||
}
|
||||
|
||||
/* Function: tetris_piece_change
|
||||
/* Function: tetris_piece_changeShape
|
||||
* 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,
|
||||
void tetris_piece_changeShape(tetris_piece_t *pPc,
|
||||
tetris_piece_shape_t shape)
|
||||
{
|
||||
assert(pPc != NULL);
|
||||
|
@ -131,3 +131,38 @@ void tetris_piece_change(tetris_piece_t *pPc,
|
|||
|
||||
pPc->shape = shape;
|
||||
}
|
||||
|
||||
|
||||
/* Function: tetris_piece_changeAngle
|
||||
* Description: changes the angle of a piece
|
||||
* Argument pPc: piece to change
|
||||
* Argument angle: the angle of interest
|
||||
* Return value: void
|
||||
*/
|
||||
void tetris_piece_changeAngle(tetris_piece_t *pPc,
|
||||
tetris_piece_angle_t angle)
|
||||
{
|
||||
assert(pPc != NULL);
|
||||
assert((angle >= TETRIS_PC_ANGLE_0) && (angle <= TETRIS_PC_ANGLE_270));
|
||||
|
||||
pPc->angle = angle;
|
||||
}
|
||||
|
||||
|
||||
/* Function: tetris_piece_angleCount
|
||||
* Description: returns the number of different angles
|
||||
* Argument pPc: piece whose angle count is of interest
|
||||
* Return value: number of different angles
|
||||
*/
|
||||
int8_t tetris_piece_angleCount(tetris_piece_t *pPc)
|
||||
{
|
||||
assert(pPc != NULL);
|
||||
|
||||
static const int8_t angleCounts[] PROGMEM = {2, 4, 1, 4, 4, 2, 2};
|
||||
|
||||
#ifdef __AVR__
|
||||
return pgm_read_word(&angleCounts[pPc->shape]);
|
||||
#else
|
||||
return angleCounts[pPc->shape];
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -93,14 +93,32 @@ void tetris_piece_rotate(tetris_piece_t *pPc,
|
|||
tetris_piece_rotation_t r);
|
||||
|
||||
|
||||
/* Function: tetris_piece_change
|
||||
/* Function: tetris_piece_changeShape
|
||||
* 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,
|
||||
void tetris_piece_changeShape(tetris_piece_t *pPc,
|
||||
tetris_piece_shape_t shape);
|
||||
|
||||
#endif /*TETRIS_PIECE_H_*/
|
||||
|
||||
/* Function: tetris_piece_changeAngle
|
||||
* Description: changes the angle of a piece
|
||||
* Argument pPc: piece to change
|
||||
* Argument angle: the angle of interest
|
||||
* Return value: void
|
||||
*/
|
||||
void tetris_piece_changeAngle(tetris_piece_t *pPc,
|
||||
tetris_piece_angle_t angle);
|
||||
|
||||
|
||||
/* Function: tetris_piece_angleCount
|
||||
* Description: returns the number of different angles
|
||||
* Argument pPc: piece whose angle count is of interest
|
||||
* Return value: int8_t
|
||||
*/
|
||||
int8_t tetris_piece_angleCount(tetris_piece_t *pPc);
|
||||
|
||||
|
||||
#endif /*TETRIS_PIECE_H_*/
|
||||
|
|
Loading…
Reference in New Issue