All pastes #443952 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-17 03:17 UTC
rendered paste body
	public void checkCombos()
	{
		//	checking each line downward
		
		int counter = 0;
		
		for (int x=0; x < blocks.length; x++) // X axis
		{
			for (int y=0; y < blocks[0].length; y++) // Y axis
			{
				
				if (y == blocks[0].length - 1)
				{
					if (counter >= 2)
					{
						//blocks[x][y].setColor(Color.BLACK);
						for (int i=counter; i >= 0; i--)
							blocks[x][y-i].setColor(Color.BLACK);
					}
					break;
				}
				else if(blocks[x][y].getColor().equals(blocks[x][y+1].getColor()))
				{
					counter++;
				}
				else
				{
					if (counter >= 2) // counter # before this
					{
						for (int i=counter; i >= 0; i--)
							blocks[x][y-i].setColor(Color.BLACK);

					}
					counter = 0;
				}
				//System.out.println("AT: " + x + "," + y + ": " +counter);
			}
			counter = 0;
		}
		
		// counting left to right
		counter = 0;
		
		for (int y=0; y < blocks[0].length; y++) // Y axis	
		{
			for (int x=0; x < blocks.length; x++) // X axis
			{
				
				if (x == blocks.length - 1)
				{
					if (counter >= 2)
					{
						for (int i=counter; i >= 0; i--)
							blocks[x-i][y].setColor(Color.BLACK);
					}
					break;
				}
				else if(blocks[x][y].getColor().equals(blocks[x+1][y].getColor()))
				{
					counter++;
				}
				else
				{
					if (counter >= 2) // counter # before this
					{
						for (int i=counter; i >= 0; i--)
							blocks[x-i][y].setColor(Color.BLACK);

					}
					counter = 0;
				}
				//System.out.println("AT: " + x + "," + y + ": " +counter);
			}
			counter = 0;
		}
		checkDrops();
	}