How Best To Handle 2D Graphics
I recently finished making a basic Tetris clone and it works fine. Only problem is there is an annoying flicker every time the screen is updated and it's given me cause to revise my paint() method which draws to the screen.
Is it perhaps purely because my paint method is too inefficient? How would others choose to output 2D graphics for simple arcade games such as Tetris or Breakout?
Currently I have a picturebox which I've set up a graphics object within to which I draw upon. I chose to do this purely 'cause this is the only form of specific graphic output I've come across in the short year that I've been learning C#. Was this wise or are there other, better methods of drawing to the screen?
Also I've been using nothing but filled rectangles to represent the squares of the game, would things maybe work more smoothly if I used small bitmaps or something instead?
Here's my current paint() method:
Thanks for any help you can give.
public void paint()
SolidBrush squarepen = null;
//reads in the array of the pile and fills the corresponding squares of the grid
for (int i = 0; i < Pile.pile.GetLength(0); i++)
for (int j = 0; j < Pile.pile.GetLength(1); j++)
if (Pile.pile[i, j] != null)
squarepen = new SolidBrush(Pile.pile[i, j].getColour());
grphPicBoxGameArea.FillRectangle(squarepen, i * 30, (j * 30) - 120, 30, 30);
//reads in the array of the current block and fills the corresponding squares of the grid
Square currentblock = blockinuse.getBlockSquares();
for (int i = 0; i < currentblock.GetLength(0); i++)
int currentxpos = currentblock[i].getXpos(), currentypos = currentblock[i].getYpos();
squarepen = new SolidBrush(currentblock[i].getColour());
grphPicBoxGameArea.FillRectangle(squarepen, currentxpos * 30, (currentypos * 30) - 120, 30, 30);