I've got the following code and wanted to know whether there was a way for me to assign the brickImage
property to the array featured in my code. If so, how do I achieve this? I basically want to create an array of bricks to be displayed in multiple rows etc.
public class Brick
{
private int x, y, width, height;
private Image brickImage;
private Rectangle brickRec;
private Rectangle[] brickRecs;
public Rectangle BrickRec
{
get { return brickRec; }
}
public Brick()
{
x = 0;
y = 0;
width = 60;
height = 20;
brickImage = Breakout.Properties.Resources.brick_fw;
brickRec = new Rectangle(x, y, width, height);
Rectangle[] brickRecs =
{
new Rectangle(0, 0, 60, 20),
new Rectangle(0, 0, 121, 20),
new Rectangle(0, 0, 242, 20)
};
}
public void drawBrick(Graphics paper)
{
paper.DrawImage(brickImage, brickRec);
//paper.DrawImage(brickImage, brickRecs);
}
}
if you want to attach an image to a rectangle simply create your own class:
then add this somewhere in your code