Пример #1
0
void TileList::removeAll(int x, int y){

	//keep calling remove until there's no more tiles at the coordinates
	while(indexOfTopTile(x,y) != -1){
		remove(x,y);
	}
}
Пример #2
0
void TileList::remove(int x, int y){

	//get the tile
	int index = indexOfTopTile(x,y);

	//there was no tile
	if (index == -1) return;

	removeTile(index);
}
Пример #3
0
void TileList::remove(int x, int y)
{
    int topTile = indexOfTopTile(x, y);
    if(topTile != -1){
        for (int i = topTile; i < m_size; i++){
                m_elements[i] = m_elements[i+1];
            }
         m_size--;
        }
}
Пример #4
0
void TileList::removeAll(int x, int y)
{
    for(int i = 0; i < m_size; ++i){
        int indexTop = indexOfTopTile(x, y);
        if(indexTop != -1){
            for(int j = indexTop; j < m_size; ++j){
                m_elements[j] = m_elements[1+j];
            }
        }
    }
}
Пример #5
0
void TileList::raise(int x, int y){

	//get the tile
	int index = indexOfTopTile(x,y);

	//there was no tile
	if (index == -1) return;

	Tile tile = tileArray[index];

	//remove the tile from its current place and add it to the end of the list
	removeTile(index);
	addTile(tile);
}
Пример #6
0
void TileList::raise(int x, int y){
    int indexTop = indexOfTopTile(x, y);
    Tile tempTopTile = m_elements[indexTop];
    if(indexTop != -1){
        for (int i = indexTop; i < m_size; ++i){
            if(i < (m_size-1)){
                m_elements[i] = m_elements[i+1];
            }
            else{
                m_elements[i] = tempTopTile;
            }
        }
    }
}
Пример #7
0
void TileList::lower(int x, int y)
{
    int indexTop = indexOfTopTile(x, y);
    Tile tempTopTile = m_elements[indexTop];
    if(indexTop != -1){
        for(int i = indexTop; i >= 0; --i){
            if(i != 0){
            m_elements[i] = m_elements[i-1];         //Shift elements right to make room at the top
            }
            else{
                m_elements[i] = tempTopTile;
            }
        }
    }
}
Пример #8
0
void TileList::lower(int x, int y){

	//get the tile
	int index = indexOfTopTile(x,y);

	//there was no tile
	if (index == -1) return;

	Tile tile = tileArray[index];

	//remove the tile but increment currentSize since we want to keep the size of the array
	removeTile(index);
	currentSize++;

	//shift the array and put tile in the first spot
	for (int i = currentSize - 2; i >= 0; --i){
		tileArray[i + 1] = tileArray[i];
	}

	//add the tile to the start of the array
	tileArray[0] = tile;
}