Closed Thread
Results 1 to 3 of 3

Thread: saving tetris blocks

  1. #1
    AzaraT is offline Newbie
    Join Date
    Oct 2009
    Posts
    13
    Rep Power
    0

    saving tetris blocks

    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:
    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);
    this is for the z block. the 2 is the center of the brick (the starting point / startx,starty).

    Anyone know how to do this?

    Thanks

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Delever is offline Newbie
    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Re: saving tetris blocks

    Quote Originally Posted by AzaraT View Post
    /*
    * 00000
    * 01200
    * 00110
    * 00000
    */

    Anyone know how to do this?

    Thanks
    Yeah, I did tetris once too

    I declared piece templates like this:

    Code:
            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 },
                    },
                }
            );
    However, I needed to write some crazy universal rotation function which would be able to find center of any piece. Somehow I succeeded

  4. #3
    AzaraT is offline Newbie
    Join Date
    Oct 2009
    Posts
    13
    Rep Power
    0

    Re: saving tetris blocks

    hehe thank you for the respond I did found another solution though

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. My shapes do not appear on the map (Tetris game)
    By ketybrown in forum C and C++
    Replies: 6
    Last Post: 04-15-2011, 01:45 PM
  2. code blocks
    By eman ahmed in forum C and C++
    Replies: 5
    Last Post: 08-28-2010, 02:29 AM
  3. Tetris Project. Need a mentor or two.
    By DMK741 in forum Community Projects
    Replies: 2
    Last Post: 07-05-2010, 03:49 AM
  4. functinoal blocks
    By mortal_king in forum C# Programming
    Replies: 0
    Last Post: 05-01-2010, 03:02 PM
  5. Tetris game - block problem.
    By Grogerian in forum Java Help
    Replies: 1
    Last Post: 09-30-2009, 05:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts