// set all the cards to the un-compressed position, then re-compress them.
void Game::resetStack( sf::Vector2i card )
{

  for ( unsigned int y = card.y; y < board[card.x].size(); y++ )
    board[ card.x ][ y ]->shape.setPosition( absoluteCardPosition( card.x, y ) );

  resizeStack( card.x );
}
Exemple #2
0
bool Stack::push (int data)
{
  if (!resizeStack ())
	return false;
  top++;
  stackArr[top] = data;
  return true;
}
// moves the card(s) on top of, and including, card x,y onto the top of stack newX.
void Game::moveCards( unsigned int x, unsigned int y, unsigned int newX )
{

  for ( unsigned int i = y; i < board[x].size(); i++ )
  {
    board[x][i]->shape.setPosition( relativeCardPosition( newX, board[newX].size() ) );
    board[newX].push_back( board[x][i] );
    board[x].erase( board[x].begin() + i );
    i--; // is this sloppy? i feel like i should have found a way to do this without changing i.
  }

  if ( board[x].size() > 0 )
    if ( board[x][ y - 1 ]->shape.getTexture() == board[x][ y - 1 ]->back )
      board[x][ y - 1 ]->shape.setTexture( board[x][ y - 1 ]->face );

  if ( board[ newX ].size() > 12 )
    completeStack( newX );

  resizeStack( newX );
  resizeStack( x );
}
Exemple #4
0
void push(stack *s, int x) {
	if (s->size == s->allocated)
		resizeStack(s);

	s->data[s->size++] = x;
}