2

I would first like to note that I am NOT using any XNA or LINQ in this small project. Basically, I want to make a clone of Tetris using C# windows application. I have already drawn out my grid, my picturebox size 250x500, making each square block 25 pixels x 25 pixels.

Now, I am an amateur at drawing shapes. I can draw lines and rectangles, circles, ellipses, and polygons on a grid, and I can fill them in with a color, etc. That's it really. I cannot do much else with drawing. Basic shapes in other words, using Points I created to draw polygons such as the "T" shape in tetris.

My question is, when making my Tetris shapes, should I draw them using the Drawing methods in C# or should I create and import bitmap pictures of the tetris shapes and use those to create my tetris clone?

Once I can figure out how to draw shapes, the rest I can figure out on my own. Also, when doing work on the game grid, do I inherit the Picturebox Properties from my class called GameGrid?

Karim O.
  • 1,325
  • 6
  • 22
  • 36
  • 1
    This definitely depends on the goal of your project. If your goal is to just make a tetris clone, then you can do whichever you want to do! You will have prettier graphics if you use bitmaps (or anyway, the potential for prettier graphics), but it might be easier/faster to just draw some colored squares. On the other hand, if your goals include learning to make a game the way most people do it, you might want to go the bitmap route, since that is far more common. Really there is no right or wrong answer here. – livingtech Mar 10 '13 at 21:48

2 Answers2

0

Using bitmap and prerendered images are preferred, becuase it speeds up rendering of each frame. This is what most of such a games do.

Mohammad Dehghan
  • 17,853
  • 3
  • 55
  • 72
0

The way that you render the shapes will have an effect on your collision detection. For instance, if you a bitmap of the T shape, you will have to have a method of detecting when the T has collided by perhaps per-pixel collision or a seperate structure which maintains the specific shape. Whereas, if you simply maintain a list of the blocks in use, collision detection becomes far simpler.

If you have your shapes as a matrix of blocks, much like the original game, you may find the rendering, handling and collision far easier.

For instance, have a look at the following pseudo-code:

class Shape
{
    bool [3][3] Blocks;

    Pos pos;
}

Shape T = new Shape();

T.Blocks[0][0] = true;
T.Blocks[0][1] = true;
T.Blocks[0][2] = true;

T.Blocks[1][0] = false;
T.Blocks[1][1] = true;
T.Blocks[1][2] = false;

T.Blocks[2][0] = false;
T.Blocks[2][1] = true;
T.Blocks[2][2] = false;

When rendering, you can do something along the following lines:

foreach(Shape s in currentBlocks)
{
    for(int x = 0; i < 3)
    {
        for(int y = 0; y < 3; y++)
        {
            if(s.Blocks[x][y])
            {
                gameGrid.Render(s.Pos.X + x, s.Pos.Y + y);
            }
        }
    }
}
rhughes
  • 9,257
  • 11
  • 59
  • 87
  • Thanks for the feedback. I have made my pieces using photoshop, since each block is 25x25 pixels, all saved with a .bmp extension. The whole purpose of this personal project is to get used to working with images and using multi-dimensional arrays. – Karim O. Mar 11 '13 at 07:14
  • @KarimOumghar Perfect. The above code example is a good use of multi-dimensional arrays. Each `block` piece can be rendered with your 25x25 pixel image. You can also go further by adding different colors for each block etc... – rhughes Mar 11 '13 at 07:19