I am creating Blokus, and I am creating the game pieces by creating an array that draws a single, one tile image to create a full piece (i.e. a T would consist of 5 tile images placed into an array, which is not always a perfect square), I can move them around the board, but when it comes to rotating the piece, I am not sure what to do.
"T" piece button code
private void TButton_Click(object sender, EventArgs e)
{
//Tile ID 16
tileWidth = 3;
tileHeight = 3;
generateNewPiece(16);
}
Relevant portion of generating the piece
public void generateNewPiece(byte tileNum)
{
pieceArray = new Cell[tileWidth, tileHeight];
buttonClicked = tileNum;
switch (tileNum)
{
case 16:
pieceArray[0, 0] = new Cell(false);
pieceArray[0, 1] = new Cell(true, currentPlayer, tileImages[currentPlayer], 40, 0);
pieceArray[0, 2] = new Cell(false);
pieceArray[1, 0] = new Cell(false);
pieceArray[1, 1] = new Cell(true, currentPlayer, tileImages[currentPlayer], 40, 40);
pieceArray[1, 2] = new Cell(false);
pieceArray[2, 0] = new Cell(true, currentPlayer, tileImages[currentPlayer], 0, 80);
pieceArray[2, 1] = new Cell(true, currentPlayer, tileImages[currentPlayer], 40, 80);
pieceArray[2, 2] = new Cell(true, currentPlayer, tileImages[currentPlayer], 80, 80);
pieceGenerated = true;
break;
}
Cell class
public class Cell
{
public bool hasImage;
public int color;
public int x, y;
public Image cellImage;
//Resources.iconname
public Cell()
{
this.hasImage = false;
this.color = 0;
this.cellImage = null;
this.x = 0;
this.y = 0;
}
public Cell(bool hasImage)
{
this.hasImage = hasImage;
}
public Cell(bool hasImage, int x, int y)
{
this.hasImage = hasImage;
this.x = x;
this.y = y;
}
public Cell(bool hasImage, int color, Image image, int x, int y)
{
this.hasImage = hasImage;
this.color = color;
this.cellImage = image;
this.x = x;
this.y = y;
}
}