Hello,
I'm currently developing a tetris clone and I have a problem saving the blocks.
I want to save the blocks in a two-dimensional array that represent the game grid (10x20). I simply want to change the values of the array if there is a block in that specific coordinate.
I'm currently creating blocks like this:
this is for the z block. the 2 is the center of the brick (the starting point / startx,starty).Code:/* * 00000 * 01200 * 00110 * 00000 */ g.FillRectangle(System.Drawing.Brushes.Red, startx - width, starty, height, width); g.DrawRectangle(System.Drawing.Pens.Black, startx - width, starty, height, width); g.FillRectangle(System.Drawing.Brushes.Red, startx, starty, height, width); g.DrawRectangle(System.Drawing.Pens.Black, startx, starty, height, width); g.FillRectangle(System.Drawing.Brushes.Red, startx, starty + height, height, width); g.DrawRectangle(System.Drawing.Pens.Black, startx, starty + height, height, width); g.FillRectangle(System.Drawing.Brushes.Red, startx + width, starty + height, height, width); g.DrawRectangle(System.Drawing.Pens.Black, startx + width, starty + height, height, width);
Anyone know how to do this?
Thanks![]()
Yeah, I did tetris once too
I declared piece templates like this:
However, I needed to write some crazy universal rotation function which would be able to find center of any piece. Somehow I succeededCode:private static List<int[,]> pieceTemplates = new List<int[,]> ( // you can modify this :) // the reason it is integer array and not, say, boolean - to make it easy to modify new int[][,] { new int[,] { { 0,1,0 }, { 1,1,1 }, }, new int[,] { { 1,1,1 }, { 0,1,0 }, }, new int[,] { { 0,1 }, { 1,1 }, { 0,1 }, }, new int[,] { { 1,0 }, { 1,1 }, { 1,0 }, }, new int[,] { { 0,1,1 }, { 1,1,0 }, }, new int[,] { { 1,1,0 }, { 0,1,1 }, }, new int[,] { { 1,0 }, { 1,1 }, { 0,1 }, }, new int[,] { { 0,1 }, { 1,1 }, { 1,0 }, }, new int[,] { { 1,0,0 }, { 1,1,1 }, }, new int[,] { { 0,0,1 }, { 1,1,1 }, }, new int[,] { { 1,1,1 }, { 1,0,0 }, }, new int[,] { { 1,1,1 }, { 0,0,1 }, }, new int[,] { { 1,1 }, { 0,1 }, { 0,1 }, }, new int[,] { { 0,1 }, { 0,1 }, { 1,1 }, }, new int[,] { { 1,1 }, { 1,0 }, { 1,0 }, }, new int[,] { { 1,0 }, { 1,0 }, { 1,1 }, }, new int[,] { { 1 }, { 1 }, { 1 }, { 1 }, }, new int[,] { { 1, 1, 1, 1 }, }, } );![]()
hehe thank you for the respondI did found another solution though
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks