Exemplo n.º 1
0
void update_snake_tail(snake * cur_snake, board * cur_board)
/*! If the given snake's growth counter is 0, advance the tail of the
    given snake one cell (by removing the current snake tail).
    If the snake's growth counter is positive, decrement the growth
    counter and do not move the snake's tail.
*/
{ 
    /* Implement me! */
    if(cur_snake->growth != 0){
        cur_snake->growth -= 1; //decrement growth counter if there is food
    }
    else{
        remove_snake_tail(cur_snake, cur_board); //delete the last node
    }
    
    
            
}
Exemplo n.º 2
0
void update_snake_tail(snake * cur_snake, board * cur_board)
/*! If the given snake's growth counter is 0, advance the tail of the
    given snake one cell (by removing the current snake tail).
    If the snake's growth counter is positive, decrement the growth
    counter and do not move the snake's tail.
*/
{
    /* do nothing if it has no pieces */
    if(cur_snake->tail == NULL)
	{
	}

    else
    {
    	if(cur_snake->growth == 0)
            remove_snake_tail(cur_snake, cur_board);

        else if( cur_snake->growth > 0 )
	    cur_snake->growth--;
    }

}